diff --git a/plugin/code_lens.py b/plugin/code_lens.py
index 87fa8eddb..d3673a844 100644
--- a/plugin/code_lens.py
+++ b/plugin/code_lens.py
@@ -23,7 +23,7 @@ def __init__(self, data: CodeLens, view: sublime.View, session_name: str) -> Non
self.region = range_to_region(data['range'], view)
self.session_name = session_name
self.annotation = '...'
- self.resolve_annotation()
+ self.resolve_annotation(view.id())
self.is_resolve_error = False
def __repr__(self) -> str:
@@ -42,7 +42,7 @@ def to_lsp(self) -> CodeLensExtended:
def small_html(self) -> str:
return '{}'.format(self.annotation)
- def resolve_annotation(self) -> None:
+ def resolve_annotation(self, view_id: int) -> None:
command = self.data.get('command')
if command is not None:
command_name = command.get('command')
@@ -51,7 +51,7 @@ def resolve_annotation(self) -> None:
'session_name': self.session_name,
'command_name': command_name,
'command_args': command.get('arguments', []),
- })
+ }, view_id=view_id)
else:
self.annotation = html_escape(command['title'])
else:
@@ -64,7 +64,7 @@ def resolve(self, view: sublime.View, code_lens_or_error: Union[CodeLens, Error]
return
self.data = code_lens_or_error
self.region = range_to_region(code_lens_or_error['range'], view)
- self.resolve_annotation()
+ self.resolve_annotation(view.id())
class CodeLensView:
diff --git a/plugin/core/views.py b/plugin/core/views.py
index 36f2a7478..03193057c 100644
--- a/plugin/core/views.py
+++ b/plugin/core/views.py
@@ -787,10 +787,10 @@ def make_link(href: str, text: Any, class_name: Optional[str] = None) -> str:
def make_command_link(command: str, text: str, command_args: Optional[Dict[str, Any]] = None,
- class_name: Optional[str] = None, view: Optional[sublime.View] = None) -> str:
- if view:
+ class_name: Optional[str] = None, view_id: Optional[int] = None) -> str:
+ if view_id is not None:
cmd = "lsp_run_text_command_helper"
- args = {"view_id": view.id(), "command": command, "args": command_args} # type: Optional[Dict[str, Any]]
+ args = {"view_id": view_id, "command": command, "args": command_args} # type: Optional[Dict[str, Any]]
else:
cmd = command
args = command_args
@@ -1014,7 +1014,7 @@ def format_diagnostic_for_html(
def format_completion(
- item: CompletionItem, index: int, can_resolve_completion_items: bool, session_name: str
+ item: CompletionItem, index: int, can_resolve_completion_items: bool, session_name: str, view_id: int
) -> sublime.CompletionItem:
# This is a hot function. Don't do heavy computations or IO in this function.
@@ -1030,7 +1030,8 @@ def format_completion(
details = [] # type: List[str]
if can_resolve_completion_items or item.get('documentation'):
- details.append(make_command_link('lsp_resolve_docs', "More", {'index': index, 'session_name': session_name}))
+ details.append(make_command_link(
+ 'lsp_resolve_docs', "More", {'index': index, 'session_name': session_name}, view_id=view_id))
if lsp_label_detail and (lsp_label + lsp_label_detail).startswith(lsp_filter_text):
trigger = lsp_label + lsp_label_detail
diff --git a/plugin/documents.py b/plugin/documents.py
index cc3913c70..c2c6da897 100644
--- a/plugin/documents.py
+++ b/plugin/documents.py
@@ -640,7 +640,8 @@ def _on_code_actions(self, responses: List[CodeActionsByConfigName]) -> None:
else:
title = all_actions[0]['title']
title = "
".join(textwrap.wrap(title, width=30))
- code_actions_link = make_command_link('lsp_code_actions', title, {"code_actions_by_config": responses})
+ code_actions_link = make_command_link(
+ 'lsp_code_actions', title, {"code_actions_by_config": responses}, view_id=self.view.id())
annotations = ["