Mercurial > forks > helix
changeset 6798:85ab75912189
Use 'ui.text' as a base style for the syntax highlighter
This fixes a regression from the refactor of the highlighters when
switching to tree-house. The old `StyleIter` used `renderer.text_style`
as the base style rather than `Style::default()` for syntax highlights.
The result was that any text not captured by a syntax highlight query
was styled with no foreground or background, defaulting to the
terminal's foreground/background. This could cause text in markdown
files to look off-colored depending on your terminal configuration.
(Though you wouldn't notice if your 'ui.text' theming matches your
terminal's theming.)
author | Michael Davis <mcarsondavis@gmail.com> |
---|---|
date | Fri, 16 May 2025 10:52:46 -0400 |
parents | def567db4436 |
children | 1b2e7ff7125d |
files | helix-term/src/ui/document.rs |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/helix-term/src/ui/document.rs Fri May 16 21:32:29 2025 +0700 +++ b/helix-term/src/ui/document.rs Fri May 16 10:52:46 2025 -0400 @@ -77,7 +77,8 @@ let mut formatter = DocumentFormatter::new_at_prev_checkpoint(text, text_fmt, text_annotations, anchor); - let mut syntax_highlighter = SyntaxHighlighter::new(syntax_highlighter, text, theme); + let mut syntax_highlighter = + SyntaxHighlighter::new(syntax_highlighter, text, theme, renderer.text_style); let mut overlay_highlighter = OverlayHighlighter::new(overlay_highlights, theme); let mut last_line_pos = LinePos { @@ -477,17 +478,24 @@ /// finished. pos: usize, theme: &'t Theme, + text_style: Style, style: Style, } impl<'h, 'r, 't> SyntaxHighlighter<'h, 'r, 't> { - fn new(inner: Option<Highlighter<'h>>, text: RopeSlice<'r>, theme: &'t Theme) -> Self { + fn new( + inner: Option<Highlighter<'h>>, + text: RopeSlice<'r>, + theme: &'t Theme, + text_style: Style, + ) -> Self { let mut highlighter = Self { inner, text, pos: 0, theme, - style: Style::default(), + style: text_style, + text_style, }; highlighter.update_pos(); highlighter @@ -516,7 +524,7 @@ let (event, highlights) = highlighter.advance(); let base = match event { - HighlightEvent::Refresh => Style::default(), + HighlightEvent::Refresh => self.text_style, HighlightEvent::Push => self.style, };