Skip to content

Commit 98d391a

Browse files
authored
Don't replace builtin rename_path command (#2764)
1 parent f0a83a5 commit 98d391a

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

Side Bar.sublime-menu

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[
2+
{ "caption": "-", "id": "lsp" },
3+
{ "caption": "LSP: Rename…", "command": "lsp_rename_path", "args": {"paths": []} }
4+
]

boot.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,13 +274,6 @@ def on_pre_close(self, view: sublime.View) -> None:
274274
tup[1](None)
275275
break
276276

277-
def on_window_command(
278-
self, window: sublime.Window, command_name: str, args: dict[str, Any]
279-
) -> tuple[str, dict[str, Any]] | None:
280-
if command_name == "rename_path":
281-
return ('lsp_rename_path', args)
282-
return None
283-
284277
def on_post_window_command(self, window: sublime.Window, command_name: str, args: dict[str, Any] | None) -> None:
285278
if command_name == "show_panel":
286279
wm = windows.lookup(window)

plugin/rename_file.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030

3131
class RenamePathInputHandler(sublime_plugin.TextInputHandler):
32+
3233
def __init__(self, path: str) -> None:
3334
self.path = Path(path)
3435

@@ -55,14 +56,15 @@ class LspRenamePathInputArgs(TypedDict):
5556

5657

5758
class LspRenamePathCommand(LspWindowCommand):
59+
5860
capability = 'workspace.fileOperations.willRename'
5961

6062
@staticmethod
6163
def is_case_change(path_a: str, path_b: str) -> bool:
6264
return path_a.lower() == path_b.lower() and Path(path_a).stat().st_ino == Path(path_b).stat().st_ino
6365

64-
def is_enabled(self) -> bool:
65-
return True
66+
def is_visible(self, **kwargs: dict[str, Any]) -> bool:
67+
return self.is_enabled()
6668

6769
def want_event(self) -> bool:
6870
return False

0 commit comments

Comments
 (0)