diff --git a/plugin/code_lens.py b/plugin/code_lens.py index 778d3b7f5..af006b299 100644 --- a/plugin/code_lens.py +++ b/plugin/code_lens.py @@ -196,10 +196,11 @@ def render(self, mode: str) -> None: self._phantom.update(phantoms) else: # 'annotation' self._clear_annotations() + flags = sublime.NO_UNDO accent = self.view.style_for_scope("region.greenish markup.accent.codelens.lsp")["foreground"] for index, lens in enumerate(self._flat_iteration()): self.view.add_regions( - self._region_key(lens.session_name, index), [lens.region], "", "", 0, [lens.small_html], accent) + self._region_key(lens.session_name, index), [lens.region], "", "", flags, [lens.small_html], accent) def get_resolved_code_lenses_for_region(self, region: sublime.Region) -> Generator[CodeLensExtended, None, None]: region = self.view.line(region) diff --git a/plugin/core/types.py b/plugin/core/types.py index 555e68b7f..7fac717c2 100644 --- a/plugin/core/types.py +++ b/plugin/core/types.py @@ -320,31 +320,33 @@ def r(name: str, default: Union[bool, int, str, list, dict]) -> None: set_debug_logging(self.log_debug) def highlight_style_region_flags(self, style_str: str) -> Tuple[int, int]: + default = sublime.NO_UNDO if style_str in ("background", "fill"): # Backwards-compatible with "fill" - return sublime.DRAW_NO_OUTLINE, sublime.DRAW_NO_OUTLINE - elif style_str == "outline": - return sublime.DRAW_NO_FILL, sublime.DRAW_NO_FILL - elif style_str == "stippled": - return sublime.DRAW_NO_FILL, sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_STIPPLED_UNDERLINE # noqa: E501 - else: - return sublime.DRAW_NO_FILL, sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE # noqa: E501 + style = default | sublime.DRAW_NO_OUTLINE + return style, style + if style_str == "outline": + style = default | sublime.DRAW_NO_FILL + return style, style + if style_str == "stippled": + return default | sublime.DRAW_NO_FILL, default | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_STIPPLED_UNDERLINE # noqa: E501 + return default | sublime.DRAW_NO_FILL, default | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE # noqa: E501 @staticmethod def _style_str_to_flag(style_str: str) -> Optional[int]: + default = sublime.DRAW_EMPTY_AS_OVERWRITE | sublime.DRAW_NO_FILL | sublime.NO_UNDO # This method could be a dict or lru_cache if style_str == "": - return sublime.DRAW_EMPTY_AS_OVERWRITE | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE - elif style_str == "box": - return sublime.DRAW_EMPTY_AS_OVERWRITE | sublime.DRAW_NO_FILL - elif style_str == "underline": - return sublime.DRAW_EMPTY_AS_OVERWRITE | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE # noqa: E501 - elif style_str == "stippled": - return sublime.DRAW_EMPTY_AS_OVERWRITE | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_STIPPLED_UNDERLINE # noqa: E501 - elif style_str == "squiggly": - return sublime.DRAW_EMPTY_AS_OVERWRITE | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SQUIGGLY_UNDERLINE # noqa: E501 - else: - # default style - return None + return default | sublime.DRAW_NO_OUTLINE + if style_str == "box": + return default + if style_str == "underline": + return default | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE + if style_str == "stippled": + return default | sublime.DRAW_NO_OUTLINE | sublime.DRAW_STIPPLED_UNDERLINE + if style_str == "squiggly": + return default | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SQUIGGLY_UNDERLINE + # default style (includes NO_UNDO) + return None def diagnostics_highlight_style_flags(self) -> List[Optional[int]]: """Returns flags for highlighting diagnostics on single lines per severity""" diff --git a/plugin/core/views.py b/plugin/core/views.py index 5ad99163e..94ada3ed3 100644 --- a/plugin/core/views.py +++ b/plugin/core/views.py @@ -53,9 +53,10 @@ MarkdownLangMap = Dict[str, Tuple[Tuple[str, ...], Tuple[str, ...]]] -DOCUMENT_LINK_FLAGS = sublime.HIDE_ON_MINIMAP | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE # noqa: E501 +DOCUMENT_LINK_FLAGS = sublime.HIDE_ON_MINIMAP | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_SOLID_UNDERLINE | sublime.NO_UNDO # noqa: E501 +SEMANTIC_TOKEN_FLAGS = sublime.DRAW_NO_OUTLINE | sublime.NO_UNDO -_baseflags = sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_EMPTY_AS_OVERWRITE +_baseflags = sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.DRAW_EMPTY_AS_OVERWRITE | sublime.NO_UNDO DIAGNOSTIC_SEVERITY = [ # Kind CSS class Scope for color Icon resource add_regions flags for single-line diagnostic multi-line diagnostic # noqa: E501 diff --git a/plugin/diagnostics.py b/plugin/diagnostics.py index 0e0ea5831..2495abbb7 100644 --- a/plugin/diagnostics.py +++ b/plugin/diagnostics.py @@ -23,7 +23,7 @@ def _annotation_region_key(self, severity: DiagnosticSeverity) -> str: return 'lsp_da-{}-{}'.format(severity, self._config_name) def draw(self, diagnostics: List[Tuple[Diagnostic, sublime.Region]]) -> None: - flags = sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE + flags = sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.NO_UNDO max_severity_level = userprefs().show_diagnostics_annotations_severity_level # To achieve the correct order of annotations (most severe having priority) we have to add regions from the # most to the least severe. diff --git a/plugin/documents.py b/plugin/documents.py index a3b3188fb..49653a875 100644 --- a/plugin/documents.py +++ b/plugin/documents.py @@ -695,7 +695,7 @@ def _on_code_actions(self, responses: List[CodeActionsByConfigName]) -> None: regions = [sublime.Region(region.b, region.a)] scope = "" icon = "" - flags = sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE + flags = sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.NO_UNDO annotations = [] annotation_color = "" if userprefs().show_code_actions == 'bulb': diff --git a/plugin/references.py b/plugin/references.py index ecae586a5..df6073c79 100644 --- a/plugin/references.py +++ b/plugin/references.py @@ -190,7 +190,7 @@ def _show_references_in_output_panel(self, word: str, session: Session, location }) # highlight all word occurrences regions = panel.find_all(r"\b{}\b".format(word)) - panel.add_regions('ReferenceHighlight', regions, 'comment', flags=sublime.DRAW_NO_FILL) + panel.add_regions('ReferenceHighlight', regions, 'comment', flags=sublime.DRAW_NO_FILL | sublime.NO_UNDO) def _get_relative_path(base_dir: Optional[str], file_path: str) -> str: diff --git a/plugin/session_buffer.py b/plugin/session_buffer.py index 2012b97c7..ce798a269 100644 --- a/plugin/session_buffer.py +++ b/plugin/session_buffer.py @@ -40,6 +40,7 @@ from .core.views import MissingUriError from .core.views import range_to_region from .core.views import region_to_range +from .core.views import SEMANTIC_TOKEN_FLAGS from .core.views import text_document_identifier from .core.views import will_save from .inlay_hint import inlay_hint_to_phantom @@ -668,7 +669,7 @@ def _draw_semantic_tokens_async(self) -> None: 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("lsp_semantic_{}".format(region_key), regions, scope, flags=sublime.DRAW_NO_OUTLINE) + sv.view.add_regions("lsp_semantic_{}".format(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: diff --git a/plugin/session_view.py b/plugin/session_view.py index addfd68ae..b9978d287 100644 --- a/plugin/session_view.py +++ b/plugin/session_view.py @@ -300,7 +300,7 @@ def present_diagnostics_async( self, is_view_visible: bool, data_per_severity: Dict[Tuple[int, bool], DiagnosticSeverityData] ) -> None: flags = userprefs().diagnostics_highlight_style_flags() # for single lines - multiline_flags = None if userprefs().show_multiline_diagnostics_highlights else sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE # noqa: E501 + multiline_flags = sublime.NO_UNDO if userprefs().show_multiline_diagnostics_highlights else sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.NO_UNDO # noqa: E501 level = userprefs().show_diagnostics_severity_level for sev in reversed(range(1, len(DIAGNOSTIC_SEVERITY) + 1)): self._draw_diagnostics( @@ -320,7 +320,7 @@ def _draw_diagnostics( flags: int, multiline: bool ) -> None: - ICON_FLAGS = sublime.HIDE_ON_MINIMAP | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE + ICON_FLAGS = sublime.HIDE_ON_MINIMAP | sublime.DRAW_NO_FILL | sublime.DRAW_NO_OUTLINE | sublime.NO_UNDO key = self.diagnostics_key(severity, multiline) tags = {tag: TagData('{}_tags_{}'.format(key, tag)) for tag in DIAGNOSTIC_TAG_VALUES} data = data_per_severity.get((severity, multiline)) @@ -341,7 +341,8 @@ def _draw_diagnostics( self.view.erase_regions("{}_underline".format(key)) for data in tags.values(): if data.regions: - self.view.add_regions(data.key, data.regions, data.scope, flags=sublime.DRAW_NO_OUTLINE) + self.view.add_regions( + data.key, data.regions, data.scope, flags=sublime.DRAW_NO_OUTLINE | sublime.NO_UNDO) else: self.view.erase_regions(data.key)