Skip to content

Commit cc7c42c

Browse files
authored
Merge branch 'main' into fix/shutdown-listeners
2 parents ac21950 + 9b6ecb6 commit cc7c42c

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

docs/src/commands.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ You can include special variables in the `command_args` array that will be autom
4343

4444
| Variable | Type | Description |
4545
| -------- | ---- | ----------- |
46-
| `"$document_id"` | object | JSON object `{ 'uri': string }` containing the file URI of the active view, see [Document Identifier](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentIdentifier) |
46+
| `"$document_id"` | object | JSON object `{ "uri": string }` containing the URI of the active view, see [TextDocumentIdentifier](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentIdentifier) |
47+
| `"$versioned_document_id"` | object | JSON object `{ "uri": string, "version": int }` containing the URI and version of the active view, see [VersionedTextDocumentIdentifier](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#versionedTextDocumentIdentifier) |
4748
| `"$file_uri"` | string | File URI of the active view |
4849
| `"$selection"` | string | Content of the (topmost) selection |
4950
| `"$offset"` | int | Character offset of the (topmost) cursor position |
5051
| `"$selection_begin"` | int | Character offset of the begin of the (topmost) selection |
5152
| `"$selection_end"` | int | Character offset of the end of the (topmost) selection |
52-
| `"$position"` | object | JSON object `{ 'line': int, 'character': int }` of the (topmost) cursor position, see [Position](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position) |
53+
| `"$position"` | object | JSON object `{ "line": int, "character": int }` of the (topmost) cursor position, see [Position](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position) |
5354
| `"$line"` | int | Zero-based line number of the (topmost) cursor position, see [Position](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position) |
5455
| `"$character"` | int | Zero-based character offset relative to the current line of the (topmost) cursor position, see [Position](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position) |
55-
| `"$range"` | object | JSON object with `'start'` and `'end'` positions of the (topmost) selection, see [Range](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#range) |
56-
| `"$text_document_position"` | object | JSON object with `'textDocument'` and `'position'` of the (topmost) selection, see [TextDocumentPositionParams](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentPositionParams) |
56+
| `"$range"` | object | JSON object with `"start"` and `"end"` positions of the (topmost) selection, see [Range](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#range) |
57+
| `"$text_document_position"` | object | JSON object with `"textDocument"` and `"position"` of the (topmost) selection, see [TextDocumentPositionParams](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentPositionParams) |

plugin/execute_command.py

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from .core.views import text_document_identifier
99
from .core.views import text_document_position_params
1010
from .core.views import uri_from_view
11+
from .core.views import versioned_text_document_identifier
1112
from typing import Any
1213
import sublime
1314

@@ -65,6 +66,8 @@ def _expand_variables(self, command_args: list[Any]) -> list[Any]:
6566
for i, arg in enumerate(command_args):
6667
if arg in ["$document_id", "${document_id}"]:
6768
command_args[i] = text_document_identifier(view)
69+
elif arg in ["$versioned_document_id", "${versioned_document_id}"]:
70+
command_args[i] = versioned_text_document_identifier(view, view.change_count())
6871
elif arg in ["$file_uri", "${file_uri}"]:
6972
command_args[i] = uri_from_view(view)
7073
elif region is not None:

plugin/session_buffer.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -677,16 +677,18 @@ def _draw_semantic_tokens_async(self) -> None:
677677
# don't update regions if there were additional changes to the buffer in the meantime
678678
if self.semantic_tokens.view_change_count != view.change_count():
679679
return
680+
session_name = self.session.config.name
680681
for region_key in self.semantic_tokens.active_region_keys.copy():
681682
if region_key not in scope_regions.keys():
682683
self.semantic_tokens.active_region_keys.remove(region_key)
683684
for sv in self.session_views:
684-
sv.view.erase_regions(f"lsp_semantic_{region_key}")
685+
sv.view.erase_regions(f"lsp_semantic_{session_name}_{region_key}")
685686
for region_key, (scope, regions) in scope_regions.items():
686687
if region_key not in self.semantic_tokens.active_region_keys:
687688
self.semantic_tokens.active_region_keys.add(region_key)
688689
for sv in self.session_views:
689-
sv.view.add_regions(f"lsp_semantic_{region_key}", regions, scope, flags=SEMANTIC_TOKEN_FLAGS)
690+
sv.view.add_regions(
691+
f"lsp_semantic_{session_name}_{region_key}", regions, scope, flags=SEMANTIC_TOKEN_FLAGS)
690692

691693
def _get_semantic_region_key_for_scope(self, scope: str) -> int:
692694
if scope not in self._semantic_region_keys:
@@ -695,8 +697,9 @@ def _get_semantic_region_key_for_scope(self, scope: str) -> int:
695697
return self._semantic_region_keys[scope]
696698

697699
def _clear_semantic_token_regions(self, view: sublime.View) -> None:
700+
session_name = self.session.config.name
698701
for region_key in self.semantic_tokens.active_region_keys:
699-
view.erase_regions(f"lsp_semantic_{region_key}")
702+
view.erase_regions(f"lsp_semantic_{session_name}_{region_key}")
700703

701704
def set_semantic_tokens_pending_refresh(self, needs_refresh: bool = True) -> None:
702705
self.semantic_tokens.needs_refresh = needs_refresh

plugin/session_view.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ def _initialize_region_keys(self) -> None:
140140
hover_highlight_style = userprefs().hover_highlight_style
141141
line_modes = ["m", "s"]
142142
self.view.add_regions(self.CODE_ACTIONS_KEY, r) # code actions lightbulb icon should always be on top
143+
session_name = self.session.config.name
143144
for key in range(1, 100):
144-
keys.append(f"lsp_semantic_{key}")
145+
keys.append(f"lsp_semantic_{session_name}_{key}")
145146
if document_highlight_style in ("background", "fill"):
146147
for kind in DOCUMENT_HIGHLIGHT_KIND_NAMES.values():
147148
for mode in line_modes:
@@ -151,14 +152,14 @@ def _initialize_region_keys(self) -> None:
151152
for severity in range(1, 5):
152153
for mode in line_modes:
153154
for tag in range(1, 3):
154-
keys.append(f"lsp{self.session.config.name}d{mode}{severity}_tags_{tag}")
155+
keys.append(f"lsp{session_name}d{mode}{severity}_tags_{tag}")
155156
keys.append("lsp_document_link")
156157
for severity in range(1, 5):
157158
for mode in line_modes:
158-
keys.append(f"lsp{self.session.config.name}d{mode}{severity}_icon")
159+
keys.append(f"lsp{session_name}d{mode}{severity}_icon")
159160
for severity in range(4, 0, -1):
160161
for mode in line_modes:
161-
keys.append(f"lsp{self.session.config.name}d{mode}{severity}_underline")
162+
keys.append(f"lsp{session_name}d{mode}{severity}_underline")
162163
if document_highlight_style in ("underline", "stippled"):
163164
for kind in DOCUMENT_HIGHLIGHT_KIND_NAMES.values():
164165
for mode in line_modes:

0 commit comments

Comments
 (0)