on master help sign in
ui: Only calculate span styling when it's actually in bounds
commit7bbf4c5b0675bb794bd88c070472773bd7d7e6bf authorBlaž Hrastnik <blaz@mxxn.io> dateWed 1 Dec 2021, 12:57 (5 years ago) parentd562e13
1 file changed+10−5
helix-term/src/ui/editor.rs+10−5
helix-term/src/ui/editor.rs+10−5
@@ -304,17 +304,17 @@ impl EditorView {
304304
305305 use helix_core::graphemes::{grapheme_width, RopeGraphemes};
306306
307− let style = spans.iter().fold(text_style, |acc, span| {
308− let style = theme.get(theme.scopes()[span.0].as_str());
309− acc.patch(style)
310− });
311−
312307 for grapheme in RopeGraphemes::new(text) {
313308 let out_of_bounds = visual_x < offset.col as u16
314309 || visual_x >= viewport.width + offset.col as u16;
315310
316311 if LineEnding::from_rope_slice(&grapheme).is_some() {
317312 if !out_of_bounds {
313+ let style = spans.iter().fold(text_style, |acc, span| {
314+ let style = theme.get(theme.scopes()[span.0].as_str());
315+ acc.patch(style)
316+ });
317+
318318 // we still want to render an empty cell with the style
319319 surface.set_string(
320320 viewport.x + visual_x - offset.col as u16,
@@ -345,6 +345,11 @@ impl EditorView {
345345 };
346346
347347 if !out_of_bounds {
348+ let style = spans.iter().fold(text_style, |acc, span| {
349+ let style = theme.get(theme.scopes()[span.0].as_str());
350+ acc.patch(style)
351+ });
352+
348353 // if we're offscreen just keep going until we hit a new line
349354 surface.set_string(
350355 viewport.x + visual_x - offset.col as u16,