diff --git a/plugin/session_buffer.py b/plugin/session_buffer.py index 420175143..ceb110966 100644 --- a/plugin/session_buffer.py +++ b/plugin/session_buffer.py @@ -29,6 +29,7 @@ from ..protocol import TextDocumentSyncKind from ..protocol import TextEdit from ..protocol import UnchangedDocumentDiagnosticReport +from .api import AbstractPlugin from .api import LspPlugin from .code_lens import CodeLensCache from .code_lens import LspToggleCodeLensesCommand @@ -1043,9 +1044,15 @@ def resolve_visible_code_lenses_async(self, view: sublime.View) -> None: Promise.all(promises).then(lambda _: self._on_visible_code_lenses_resolved_async()) def _filter_supported_code_lenses(self) -> list[ResolvedCodeLens]: + code_lenses_with_command = self._code_lenses.code_lenses_with_command() + if isinstance(self.session.plugin, AbstractPlugin): + # We can't filter out any commands, because we don't know which commands are handled by the + # AbstractPlugin.on_pre_server_command API method. Code lenses which are not handled by that method or by + # the server will be shown, but are not functional. + return code_lenses_with_command supported_code_lenses: list[ResolvedCodeLens] = [] # Filter out CodeLenses with commands that are not handled by the language server or plugin - for code_lens in self._code_lenses.code_lenses_with_command(): + for code_lens in code_lenses_with_command: command_name = code_lens['command']['command'] if command_name in self._supported_commands: supported_code_lenses.append(code_lens)