diff --git a/plugin/core/registry.py b/plugin/core/registry.py index ea9deab2f..1ba7c9041 100644 --- a/plugin/core/registry.py +++ b/plugin/core/registry.py @@ -41,7 +41,7 @@ def get_position(view: sublime.View, event: dict | None = None, point: int | Non if x is not None and y is not None: return view.window_to_text((x, y)) try: - return view.sel()[0].begin() + return view.sel()[0].b except IndexError: return None diff --git a/plugin/hover.py b/plugin/hover.py index 9466aa128..b3d9ddae4 100644 --- a/plugin/hover.py +++ b/plugin/hover.py @@ -16,6 +16,7 @@ from .core.protocol import Position from .core.protocol import Range from .core.protocol import Request +from .core.registry import get_position from .core.registry import LspTextCommand from .core.registry import windows from .core.sessions import AbstractViewListener @@ -23,7 +24,6 @@ from .core.settings import userprefs from .core.url import parse_uri from .core.views import diagnostic_severity -from .core.views import first_selection_region from .core.views import format_code_actions_for_quick_panel from .core.views import format_diagnostic_for_html from .core.views import FORMAT_MARKED_STRING @@ -115,17 +115,12 @@ def run( point: int | None = None, event: dict | None = None ) -> None: - temp_point = point - if temp_point is None: - region = first_selection_region(self.view) - if region is not None: - temp_point = region.begin() - if temp_point is None: + hover_point = get_position(self.view, event, point) + if hover_point is None: return wm = windows.lookup(self.view.window()) if not wm: return - hover_point = temp_point self._base_dir = wm.get_project_path(self.view.file_name() or "") self._hover_responses: list[tuple[Hover, MarkdownLangMap | None]] = [] self._document_links: list[DocumentLink] = []