diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index f0080bc36..08b8ee996 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -1619,7 +1619,7 @@ def run_code_action_async( # A code action can have an edit and/or command. Note that it can have *both*. In case both are present, we # must apply the edits before running the command. code_action = cast(CodeAction, code_action) - return self._maybe_resolve_code_action(code_action) \ + return self._maybe_resolve_code_action(code_action, view) \ .then(lambda code_action: self._apply_code_action_async(code_action, view)) def open_uri_async( @@ -1704,12 +1704,19 @@ def notify_plugin_on_session_buffer_change(self, session_buffer: SessionBufferPr if self._plugin: self._plugin.on_session_buffer_changed_async(session_buffer) - def _maybe_resolve_code_action(self, code_action: CodeAction) -> Promise[Union[CodeAction, Error]]: - if "edit" not in code_action and self.has_capability("codeActionProvider.resolveProvider"): - # TODO: Should we accept a SessionBuffer? What if this capability is registered with a documentSelector? - # We must first resolve the command and edit properties, because they can potentially be absent. - request = Request("codeAction/resolve", code_action) - return self.send_request_task(request) + def _maybe_resolve_code_action( + self, code_action: CodeAction, view: Optional[sublime.View] + ) -> Promise[Union[CodeAction, Error]]: + if "edit" not in code_action: + has_capability = self.has_capability("codeActionProvider.resolveProvider") + if not has_capability and view: + session_view = self.session_view_for_view_async(view) + if session_view: + has_capability = session_view.has_capability_async("codeActionProvider.resolveProvider") + if has_capability: + # We must first resolve the command and edit properties, because they can potentially be absent. + request = Request("codeAction/resolve", code_action) + return self.send_request_task(request) return Promise.resolve(code_action) def _apply_code_action_async(