Merge pull request #263 from zed-industries/fix-highlighting-when-x-scrolled

Paint highlighted lines correctly when horizontally scrolled
This commit is contained in:
Max Brunsfeld 2021-11-29 11:43:08 -08:00 committed by GitHub
commit 29b616f4cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -259,31 +259,18 @@ impl Line {
for glyph in &run.glyphs {
let glyph_origin = origin + baseline_offset + glyph.position;
if glyph_origin.x() + max_glyph_width < visible_bounds.origin().x() {
continue;
}
if glyph_origin.x() > visible_bounds.upper_right().x() {
break;
}
let mut finished_underline = None;
if glyph.index >= run_end {
if let Some((run_len, run_color, run_underline_color)) = style_runs.next() {
if let Some((underline_origin, underline_color)) = underline {
if let Some((_, underline_color)) = underline {
if *run_underline_color != Some(underline_color) {
cx.scene.push_underline(scene::Quad {
bounds: RectF::from_points(
underline_origin,
glyph_origin + vec2f(0., 1.),
),
background: Some(underline_color),
border: Default::default(),
corner_radius: 0.,
});
underline = None;
finished_underline = underline.take();
}
}
if let Some(run_underline_color) = run_underline_color {
underline.get_or_insert((glyph_origin, *run_underline_color));
}
@ -293,20 +280,23 @@ impl Line {
} else {
run_end = self.layout.len;
color = Color::black();
if let Some((underline_origin, underline_color)) = underline.take() {
cx.scene.push_underline(scene::Quad {
bounds: RectF::from_points(
underline_origin,
glyph_origin + vec2f(0., 1.),
),
background: Some(underline_color),
border: Default::default(),
corner_radius: 0.,
});
}
finished_underline = underline.take();
}
}
if glyph_origin.x() + max_glyph_width < visible_bounds.origin().x() {
continue;
}
if let Some((underline_origin, underline_color)) = finished_underline {
cx.scene.push_underline(scene::Quad {
bounds: RectF::from_points(underline_origin, glyph_origin + vec2f(0., 1.)),
background: Some(underline_color),
border: Default::default(),
corner_radius: 0.,
});
}
cx.scene.push_glyph(scene::Glyph {
font_id: run.font_id,
font_size: self.layout.font_size,