on master help sign in
Compute style only once per source highlight event (#1966)
420b5b8Gokul Soumya
helix-term/src/ui/editor.rs+3−8
@@ -343,6 +343,9 @@ impl EditorView {
343 // the rope, to allow cursor highlighting at the end
343 // the rope, to allow cursor highlighting at the end
344 // of the rope.
344 // of the rope.
345 let text = text.get_slice(start..end).unwrap_or_else(|| " ".into());
345 let text = text.get_slice(start..end).unwrap_or_else(|| " ".into());
346+ let style = spans
347+ .iter()
348+ .fold(text_style, |acc, span| acc.patch(theme.highlight(span.0)));
346
349
347 use helix_core::graphemes::{grapheme_width, RopeGraphemes};
350 use helix_core::graphemes::{grapheme_width, RopeGraphemes};
348
351
@@ -352,10 +355,6 @@ impl EditorView {
352
355
353 if LineEnding::from_rope_slice(&grapheme).is_some() {
356 if LineEnding::from_rope_slice(&grapheme).is_some() {
354 if !out_of_bounds {
357 if !out_of_bounds {
355− let style = spans.iter().fold(text_style, |acc, span| {
356− acc.patch(theme.highlight(span.0))
357− });
358−
359 // we still want to render an empty cell with the style
358 // we still want to render an empty cell with the style
360 surface.set_string(
359 surface.set_string(
361 viewport.x + visual_x - offset.col as u16,
360 viewport.x + visual_x - offset.col as u16,
@@ -387,10 +386,6 @@ impl EditorView {
387 };
386 };
388
387
389 if !out_of_bounds {
388 if !out_of_bounds {
390− let style = spans.iter().fold(text_style, |acc, span| {
391− acc.patch(theme.highlight(span.0))
392− });
393−
394 // if we're offscreen just keep going until we hit a new line
389 // if we're offscreen just keep going until we hit a new line
395 surface.set_string(
390 surface.set_string(
396 viewport.x + visual_x - offset.col as u16,
391 viewport.x + visual_x - offset.col as u16,