Skip to content

Commit

Permalink
improve initial_selection and rename file_name to path
Browse files Browse the repository at this point in the history
  • Loading branch information
predragnikolic committed Jun 26, 2024
1 parent 08e3af1 commit 6f65462
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plugin/rename_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,26 @@ class RenameFileInputHandler(sublime_plugin.TextInputHandler):
def want_event(self) -> bool:
return False

def __init__(self, file_name: str) -> None:
self.file_name = file_name
def __init__(self, path: str) -> None:
self.path = path

def name(self) -> str:
return "new_name"

def placeholder(self) -> str:
return self.file_name
return self.path

def initial_text(self) -> str:
return self.placeholder()

def initial_selection(self) -> list[tuple[int, int]]:
end_point = self.file_name.rfind('.')
end_point = self.path.rfind('.')
if end_point == -1:
end_point = len(self.path)
return [(0, end_point)]

def validate(self, name: str) -> bool:
return len(name) > 0
def validate(self, path: str) -> bool:
return len(path) > 0


class LspRenameFileCommand(LspWindowCommand):
Expand Down

0 comments on commit 6f65462

Please sign in to comment.