From 6b013a218c5d94b03b4b07ca78bac39b5ce736db Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sat, 20 Apr 2024 00:16:05 +0200 Subject: [PATCH 1/3] fix: check semantic capability through session buffer --- plugin/core/sessions.py | 9 ++++++--- plugin/session_buffer.py | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index 0f660af8c..05f5e75e7 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -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[List[str]], + modifiers_legend: Tuple[List[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) diff --git a/plugin/session_buffer.py b/plugin/session_buffer.py index 71febb56b..c8f56ab4d 100644 --- a/plugin/session_buffer.py +++ b/plugin/session_buffer.py @@ -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] @@ -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. From 972ab9fe25eb340ffd8a989b6cf1f306f66463cf Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sat, 20 Apr 2024 00:20:11 +0200 Subject: [PATCH 2/3] type --- plugin/core/sessions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index 05f5e75e7..8e13d6ba3 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -1815,8 +1815,8 @@ def _set_focused_sheet(self, sheet: Optional[sublime.Sheet]) -> None: def decode_semantic_token( self, - types_legend: Tuple[List[str]], - modifiers_legend: Tuple[List[str]], + types_legend: Tuple[str], + modifiers_legend: Tuple[str], token_type_encoded: int, token_modifiers_encoded: int ) -> Tuple[str, List[str], Optional[str]]: From 202e4ac158b717967a3059c10d4a188e59ce9ec5 Mon Sep 17 00:00:00 2001 From: Rafal Chlodnicki Date: Sat, 20 Apr 2024 00:20:33 +0200 Subject: [PATCH 3/3] type --- plugin/core/sessions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/core/sessions.py b/plugin/core/sessions.py index 8e13d6ba3..8bb621295 100644 --- a/plugin/core/sessions.py +++ b/plugin/core/sessions.py @@ -1815,8 +1815,8 @@ def _set_focused_sheet(self, sheet: Optional[sublime.Sheet]) -> None: def decode_semantic_token( self, - types_legend: Tuple[str], - modifiers_legend: Tuple[str], + types_legend: Tuple[str, ...], + modifiers_legend: Tuple[str, ...], token_type_encoded: int, token_modifiers_encoded: int ) -> Tuple[str, List[str], Optional[str]]: