on master help sign in
ui: Only calculate span styling when it's actually in bounds
7bbf4c5Blaž Hrastnik
helix-term/src/ui/editor.rs+10−5
@@ -304,17 +304,17 @@ impl EditorView {
304
304
305 use helix_core::graphemes::{grapheme_width, RopeGraphemes};
305 use helix_core::graphemes::{grapheme_width, RopeGraphemes};
306
306
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−
312 for grapheme in RopeGraphemes::new(text) {
307 for grapheme in RopeGraphemes::new(text) {
313 let out_of_bounds = visual_x < offset.col as u16
308 let out_of_bounds = visual_x < offset.col as u16
314 || visual_x >= viewport.width + offset.col as u16;
309 || visual_x >= viewport.width + offset.col as u16;
315
310
316 if LineEnding::from_rope_slice(&grapheme).is_some() {
311 if LineEnding::from_rope_slice(&grapheme).is_some() {
317 if !out_of_bounds {
312 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+
318 // we still want to render an empty cell with the style
318 // we still want to render an empty cell with the style
319 surface.set_string(
319 surface.set_string(
320 viewport.x + visual_x - offset.col as u16,
320 viewport.x + visual_x - offset.col as u16,
@@ -345,6 +345,11 @@ impl EditorView {
345 };
345 };
346
346
347 if !out_of_bounds {
347 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+
348 // if we're offscreen just keep going until we hit a new line
353 // if we're offscreen just keep going until we hit a new line
349 surface.set_string(
354 surface.set_string(
350 viewport.x + visual_x - offset.col as u16,
355 viewport.x + visual_x - offset.col as u16,