summaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-12-01 03:57:57 +0000
committerBlaž Hrastnik2021-12-01 03:57:57 +0000
commit7bbf4c5b0675bb794bd88c070472773bd7d7e6bf (patch)
tree79fd3bd2b2274dc04e1a5ada1702c535ed9c57d5 /helix-term
parentd562e13e1f875b1f5675ddc7ac6766a04228caaa (diff)
ui: Only calculate span styling when it's actually in bounds
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/ui/editor.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index c6d0e71f..6299014c 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -304,17 +304,17 @@ impl EditorView {
use helix_core::graphemes::{grapheme_width, RopeGraphemes};
- let style = spans.iter().fold(text_style, |acc, span| {
- let style = theme.get(theme.scopes()[span.0].as_str());
- acc.patch(style)
- });
-
for grapheme in RopeGraphemes::new(text) {
let out_of_bounds = visual_x < offset.col as u16
|| visual_x >= viewport.width + offset.col as u16;
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)
+ });
+
// we still want to render an empty cell with the style
surface.set_string(
viewport.x + visual_x - offset.col as u16,
@@ -345,6 +345,11 @@ 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)
+ });
+
// if we're offscreen just keep going until we hit a new line
surface.set_string(
viewport.x + visual_x - offset.col as u16,