diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 6299014c..a4fbca99 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -311,8 +311,7 @@ impl EditorView { if LineEnding::from_rope_slice(&grapheme).is_some() { if !out_of_bounds { let style = spans.iter().fold(text_style, |acc, span| { - let style = theme.get(theme.scopes()[span.0].as_str()); - acc.patch(style) + acc.patch(theme.highlight(span.0)) }); // we still want to render an empty cell with the style @@ -346,8 +345,7 @@ impl EditorView { if !out_of_bounds { let style = spans.iter().fold(text_style, |acc, span| { - let style = theme.get(theme.scopes()[span.0].as_str()); - acc.patch(style) + acc.patch(theme.highlight(span.0)) }); // if we're offscreen just keep going until we hit a new line diff --git a/helix-view/src/theme.rs b/helix-view/src/theme.rs index 757316bd..2366ff7d 100644 --- a/helix-view/src/theme.rs +++ b/helix-view/src/theme.rs @@ -78,8 +78,11 @@ impl Loader { #[derive(Clone, Debug)] pub struct Theme { - scopes: Vec, + // UI styles are stored in a HashMap styles: HashMap, + // tree-sitter highlight styles are stored in a Vec to optimize lookups + scopes: Vec, + highlights: Vec