Unnamed repository; edit this file 'description' to name the repository.
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.)
Michael Davis 9 months ago
parent b4e51ef · commit 3ceae88
-rw-r--r--helix-term/src/ui/document.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/helix-term/src/ui/document.rs b/helix-term/src/ui/document.rs
index d71c47a1..524d829c 100644
--- a/helix-term/src/ui/document.rs
+++ b/helix-term/src/ui/document.rs
@@ -77,7 +77,8 @@ pub fn render_text(
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 @@ struct SyntaxHighlighter<'h, 'r, 't> {
/// 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 @@ impl<'h, 'r, 't> SyntaxHighlighter<'h, 'r, 't> {
let (event, highlights) = highlighter.advance();
let base = match event {
- HighlightEvent::Refresh => Style::default(),
+ HighlightEvent::Refresh => self.text_style,
HighlightEvent::Push => self.style,
};