mirror of
https://github.com/helix-editor/helix.git
synced 2025-01-19 21:47:07 +04:00
ui: Only calculate span styling when it's actually in bounds
This commit is contained in:
parent
d562e13e1f
commit
7bbf4c5b06
@ -304,17 +304,17 @@ pub fn render_text_highlights<H: Iterator<Item = HighlightEvent>>(
|
|||||||
|
|
||||||
use helix_core::graphemes::{grapheme_width, RopeGraphemes};
|
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) {
|
for grapheme in RopeGraphemes::new(text) {
|
||||||
let out_of_bounds = visual_x < offset.col as u16
|
let out_of_bounds = visual_x < offset.col as u16
|
||||||
|| visual_x >= viewport.width + offset.col as u16;
|
|| visual_x >= viewport.width + offset.col as u16;
|
||||||
|
|
||||||
if LineEnding::from_rope_slice(&grapheme).is_some() {
|
if LineEnding::from_rope_slice(&grapheme).is_some() {
|
||||||
if !out_of_bounds {
|
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
|
// we still want to render an empty cell with the style
|
||||||
surface.set_string(
|
surface.set_string(
|
||||||
viewport.x + visual_x - offset.col as u16,
|
viewport.x + visual_x - offset.col as u16,
|
||||||
@ -345,6 +345,11 @@ pub fn render_text_highlights<H: Iterator<Item = HighlightEvent>>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if !out_of_bounds {
|
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
|
// if we're offscreen just keep going until we hit a new line
|
||||||
surface.set_string(
|
surface.set_string(
|
||||||
viewport.x + visual_x - offset.col as u16,
|
viewport.x + visual_x - offset.col as u16,
|
||||||
|
Loading…
Reference in New Issue
Block a user