From f512c96ec53cbd668dab29ab9b013423ae1300e5 Mon Sep 17 00:00:00 2001 From: deathaxe Date: Sun, 9 Jun 2024 22:38:07 +0200 Subject: [PATCH] Fix arguments error if commands are bound to mouse keys (#2492) LspTextCommands opt-in to mouse events, but not all are designed to handle required events. Therefore they fail, when being bound to mouse keys. see https://forum.sublimetext.com/t/mouse-map-always-attach-current-event-in-its-args/72502/4 This commit opts-out those commands. --- plugin/code_lens.py | 3 +++ plugin/completion.py | 3 +++ plugin/core/registry.py | 9 +++++++++ plugin/semantic_highlighting.py | 3 +++ 4 files changed, 18 insertions(+) diff --git a/plugin/code_lens.py b/plugin/code_lens.py index d38788dae..706e8fa3c 100644 --- a/plugin/code_lens.py +++ b/plugin/code_lens.py @@ -240,6 +240,9 @@ def run(self, edit: sublime.Edit) -> None: lambda i: self.on_select(code_lenses, i) ) + def want_event(self) -> bool: + return False + def on_select(self, code_lenses: list[CodeLensExtended], index: int) -> None: try: code_lens = code_lenses[index] diff --git a/plugin/completion.py b/plugin/completion.py index 1f59451e6..5b1ad1c1f 100644 --- a/plugin/completion.py +++ b/plugin/completion.py @@ -368,6 +368,9 @@ def run(self, edit: sublime.Edit, index: int, session_name: str) -> None: else: self._on_resolved(session_name, item) + def want_event(self) -> bool: + return False + def _on_resolved_async(self, session_name: str, item: CompletionItem) -> None: sublime.set_timeout(functools.partial(self._on_resolved, session_name, item)) diff --git a/plugin/core/registry.py b/plugin/core/registry.py index 1ba7c9041..2a1e5a2a3 100644 --- a/plugin/core/registry.py +++ b/plugin/core/registry.py @@ -219,6 +219,9 @@ def run(self, edit: Any, config_name: str | None = None) -> None: else: wm.window.show_quick_panel(self._config_names, partial(self.restart_server, wm)) + def want_event(self) -> bool: + return False + def restart_server(self, wm: WindowManager, index: int) -> None: if index == -1: return @@ -270,8 +273,14 @@ class LspNextDiagnosticCommand(LspTextCommand): def run(self, edit: sublime.Edit, point: int | None = None) -> None: navigate_diagnostics(self.view, point, forward=True) + def want_event(self) -> bool: + return False + class LspPrevDiagnosticCommand(LspTextCommand): def run(self, edit: sublime.Edit, point: int | None = None) -> None: navigate_diagnostics(self.view, point, forward=False) + + def want_event(self) -> bool: + return False diff --git a/plugin/semantic_highlighting.py b/plugin/semantic_highlighting.py index c5cdcbbfb..2e4fef633 100644 --- a/plugin/semantic_highlighting.py +++ b/plugin/semantic_highlighting.py @@ -30,6 +30,9 @@ class LspShowScopeNameCommand(LspTextCommand): capability = 'semanticTokensProvider' + def want_event(self) -> bool: + return False + def run(self, _: sublime.Edit) -> None: point = self.view.sel()[-1].b scope = self.view.scope_name(point).rstrip()