Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check semantic capability through session buffer #2453

Merged
merged 3 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions plugin/core/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,9 +1814,12 @@ def _set_focused_sheet(self, sheet: Optional[sublime.Sheet]) -> None:
self.window.focus_sheet(sheet)

def decode_semantic_token(
self, token_type_encoded: int, token_modifiers_encoded: int) -> Tuple[str, List[str], Optional[str]]:
types_legend = tuple(cast(List[str], self.get_capability('semanticTokensProvider.legend.tokenTypes')))
modifiers_legend = tuple(cast(List[str], self.get_capability('semanticTokensProvider.legend.tokenModifiers')))
self,
types_legend: Tuple[str, ...],
modifiers_legend: Tuple[str, ...],
token_type_encoded: int,
token_modifiers_encoded: int
) -> Tuple[str, List[str], Optional[str]]:
return decode_semantic_token(
types_legend, modifiers_legend, self._semantic_tokens_map, token_type_encoded, token_modifiers_encoded)

Expand Down
4 changes: 3 additions & 1 deletion plugin/session_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,8 @@ def _draw_semantic_tokens_async(self) -> None:
scope_regions = dict() # type: Dict[int, Tuple[str, List[sublime.Region]]]
prev_line = 0
prev_col_utf16 = 0
types_legend = tuple(cast(List[str], self.get_capability('semanticTokensProvider.legend.tokenTypes')))
modifiers_legend = tuple(cast(List[str], self.get_capability('semanticTokensProvider.legend.tokenModifiers')))
for idx in range(0, len(self.semantic_tokens.data), 5):
delta_line = self.semantic_tokens.data[idx]
delta_start_utf16 = self.semantic_tokens.data[idx + 1]
Expand All @@ -644,7 +646,7 @@ def _draw_semantic_tokens_async(self) -> None:
prev_line = line
prev_col_utf16 = col_utf16
token_type, token_modifiers, scope = self.session.decode_semantic_token(
token_type_encoded, token_modifiers_encoded)
types_legend, modifiers_legend, token_type_encoded, token_modifiers_encoded)
if scope is None:
# We can still use the meta scope and draw highlighting regions for custom token types if there is a
# color scheme rule for this particular token type.
Expand Down