Skip to content

Commit

Permalink
use session-unique region keys for semantic tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Sep 21, 2024
1 parent f4223d6 commit a28a9e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions plugin/session_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,12 +681,12 @@ def _draw_semantic_tokens_async(self) -> None:
if region_key not in scope_regions.keys():
self.semantic_tokens.active_region_keys.remove(region_key)
for sv in self.session_views:
sv.view.erase_regions(f"lsp_semantic_{region_key}")
sv.view.erase_regions(f"lsp_semantic_{self.session.config.name}_{region_key}")
for region_key, (scope, regions) in scope_regions.items():
if region_key not in self.semantic_tokens.active_region_keys:
self.semantic_tokens.active_region_keys.add(region_key)
for sv in self.session_views:
sv.view.add_regions(f"lsp_semantic_{region_key}", regions, scope, flags=SEMANTIC_TOKEN_FLAGS)
sv.view.add_regions(f"lsp_semantic_{self.session.config.name}_{region_key}", regions, scope, flags=SEMANTIC_TOKEN_FLAGS)

def _get_semantic_region_key_for_scope(self, scope: str) -> int:
if scope not in self._semantic_region_keys:
Expand All @@ -696,7 +696,7 @@ def _get_semantic_region_key_for_scope(self, scope: str) -> int:

def _clear_semantic_token_regions(self, view: sublime.View) -> None:
for region_key in self.semantic_tokens.active_region_keys:
view.erase_regions(f"lsp_semantic_{region_key}")
view.erase_regions(f"lsp_semantic_{self.session.config.name}_{region_key}")

def set_semantic_tokens_pending_refresh(self, needs_refresh: bool = True) -> None:
self.semantic_tokens.needs_refresh = needs_refresh
Expand Down
2 changes: 1 addition & 1 deletion plugin/session_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _initialize_region_keys(self) -> None:
line_modes = ["m", "s"]
self.view.add_regions(self.CODE_ACTIONS_KEY, r) # code actions lightbulb icon should always be on top
for key in range(1, 100):
keys.append(f"lsp_semantic_{key}")
keys.append(f"lsp_semantic_{self.session.config.name}_{key}")
if document_highlight_style in ("background", "fill"):
for kind in DOCUMENT_HIGHLIGHT_KIND_NAMES.values():
for mode in line_modes:
Expand Down

0 comments on commit a28a9e2

Please sign in to comment.