mirror of https://github.com/helix-editor/helix
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.)pull/13551/head
parent
b4e51ef895
commit
3ceae88c3a
|
@ -77,7 +77,8 @@ pub fn render_text(
|
||||||
|
|
||||||
let mut formatter =
|
let mut formatter =
|
||||||
DocumentFormatter::new_at_prev_checkpoint(text, text_fmt, text_annotations, anchor);
|
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 overlay_highlighter = OverlayHighlighter::new(overlay_highlights, theme);
|
||||||
|
|
||||||
let mut last_line_pos = LinePos {
|
let mut last_line_pos = LinePos {
|
||||||
|
@ -477,17 +478,24 @@ struct SyntaxHighlighter<'h, 'r, 't> {
|
||||||
/// finished.
|
/// finished.
|
||||||
pos: usize,
|
pos: usize,
|
||||||
theme: &'t Theme,
|
theme: &'t Theme,
|
||||||
|
text_style: Style,
|
||||||
style: Style,
|
style: Style,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'h, 'r, 't> SyntaxHighlighter<'h, 'r, 't> {
|
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 {
|
let mut highlighter = Self {
|
||||||
inner,
|
inner,
|
||||||
text,
|
text,
|
||||||
pos: 0,
|
pos: 0,
|
||||||
theme,
|
theme,
|
||||||
style: Style::default(),
|
style: text_style,
|
||||||
|
text_style,
|
||||||
};
|
};
|
||||||
highlighter.update_pos();
|
highlighter.update_pos();
|
||||||
highlighter
|
highlighter
|
||||||
|
@ -516,7 +524,7 @@ impl<'h, 'r, 't> SyntaxHighlighter<'h, 'r, 't> {
|
||||||
|
|
||||||
let (event, highlights) = highlighter.advance();
|
let (event, highlights) = highlighter.advance();
|
||||||
let base = match event {
|
let base = match event {
|
||||||
HighlightEvent::Refresh => Style::default(),
|
HighlightEvent::Refresh => self.text_style,
|
||||||
HighlightEvent::Push => self.style,
|
HighlightEvent::Push => self.style,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue