Skip to content

Commit

Permalink
Fix arguments error if commands are bound to mouse keys (#2492)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deathaxe authored Jun 9, 2024
1 parent 7554363 commit f512c96
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugin/code_lens.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 3 additions & 0 deletions plugin/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
9 changes: 9 additions & 0 deletions plugin/core/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions plugin/semantic_highlighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit f512c96

Please sign in to comment.