From 178adae6e086f9edc3600bdbbd1f64d98c4c2337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D1=80=D0=B0=D0=B3=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B8=D1=9B?= Date: Tue, 2 Jul 2024 15:18:06 +0200 Subject: [PATCH] remove LSP: Rename File and Rename folder in favor of LSP: Rename... in the sidebar context menu --- Side Bar.sublime-menu | 12 +++--------- plugin/rename_file.py | 16 ++++++---------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/Side Bar.sublime-menu b/Side Bar.sublime-menu index 67b0316cf..5538942d2 100644 --- a/Side Bar.sublime-menu +++ b/Side Bar.sublime-menu @@ -1,14 +1,8 @@ [ { - "caption": "Lsp: Rename File", + "caption": "LSP: Rename...", "mnemonic": "l", "command": "lsp_rename_file", - "args": {"files": []} - }, - { - "caption": "Lsp: Rename Folder", - "mnemonic": "l", - "command": "lsp_rename_file", - "args": {"dirs": []} - }, + "args": {"paths": []} + } ] diff --git a/plugin/rename_file.py b/plugin/rename_file.py index ad12cdd7c..9c785422e 100644 --- a/plugin/rename_file.py +++ b/plugin/rename_file.py @@ -38,25 +38,23 @@ class LspRenameFileCommand(LspWindowCommand): def is_enabled(self): return True - def want_event(self) -> bool: return False def input(self, args: dict) -> sublime_plugin.TextInputHandler | None: if "new_name" in args: return None - old_path = self.get_old_path(args.get('dirs'), args.get('files'), self.window.active_view()) + old_path = self.get_old_path(args.get('paths'), self.window.active_view()) return RenameFileInputHandler(Path(old_path or "").name) def run( self, new_name: str, # new_name can be: FILE_NAME.xy OR ./FILE_NAME.xy OR ../../FILE_NAME.xy - dirs: list[str] | None = None, # exist when invoked from the sidebar with "LSP: Rename Folder" - files: list[str] | None = None, # exist when invoked from the sidebar with "LSP: Rename File" + paths: list[str] | None = None, # exist when invoked from the sidebar with "LSP: Rename..." ) -> None: session = self.session() view = self.window.active_view() - old_path = self.get_old_path(dirs, files, view) + old_path = self.get_old_path(paths, view) if old_path is None: # handle renaming buffers if view: view.set_name(new_name) @@ -86,11 +84,9 @@ def run( self.rename_path(old_path, new_path) self.notify_did_rename(rename_file_params, new_path, view) - def get_old_path(self, dirs: list[str] | None, files: list[str] | None, view: sublime.View | None) -> str | None: - if dirs: - return dirs[0] - if files: - return files[0] + def get_old_path(self, paths: list[str] | None, view: sublime.View | None) -> str | None: + if paths: + return paths[0] if view: return view.file_name()