Skip to content

Commit

Permalink
fix: consider priority_selector when using best_session during rename
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Oct 25, 2024
1 parent fbbbd77 commit c7e738e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions plugin/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit c7e738e

Please sign in to comment.