From c7e738eb6c993f70b4c45d202dc99302c48c8f4b Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Fri, 25 Oct 2024 22:53:34 +0200 Subject: [PATCH] fix: consider priority_selector when using best_session during rename --- plugin/rename.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugin/rename.py b/plugin/rename.py index 309d0e5d4..721d30e70 100644 --- a/plugin/rename.py +++ b/plugin/rename.py @@ -133,19 +133,19 @@ def input(self, args: dict) -> sublime_plugin.TextInputHandler | None: if "new_name" in args: # Defer to "run" and trigger rename. return None - prepare_provider_session = self.best_session("renameProvider.prepareProvider") + point = args.get("point") + if not isinstance(point, int): + region = first_selection_region(self.view) + if region is None: + return None + point = region.b + prepare_provider_session = self.best_session("renameProvider.prepareProvider", point) if prepare_provider_session and "placeholder" not in args: # Defer to "run" and trigger "prepare" request. return None placeholder = args.get("placeholder", "") if not placeholder: - point = args.get("point") # guess the symbol name - if not isinstance(point, int): - region = first_selection_region(self.view) - if region is None: - return None - point = region.b placeholder = self.view.substr(self.view.word(point)) return RenameSymbolInputHandler(self.view, placeholder) @@ -161,7 +161,7 @@ def run( if listener: listener.purge_changes_async() location = get_position(self.view, event, point) - prepare_provider_session = self.best_session("renameProvider.prepareProvider") + prepare_provider_session = self.best_session("renameProvider.prepareProvider", point) if new_name or placeholder or not prepare_provider_session: if location is not None and new_name: self._do_rename(location, new_name) @@ -176,7 +176,7 @@ def run( request, partial(self._on_prepare_result, location), self._on_prepare_error) def _do_rename(self, position: int, new_name: str) -> None: - session = self.best_session(self.capability) + session = self.best_session(self.capability, position) if not session: return position_params = text_document_position_params(self.view, position)