Skip to content

Commit

Permalink
fix: check semantic capability through session buffer (#2453)
Browse files Browse the repository at this point in the history
* fix: check semantic capability through session buffer

* type

* type
  • Loading branch information
rchl authored Apr 20, 2024
1 parent 1c6d8bc commit 4f30db8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit 4f30db8

Please sign in to comment.