Fix off by one with end of selection

This commit is contained in:
Jeremy Soller 2022-10-19 10:20:22 -06:00
parent 190b41f387
commit 66f9fea001
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE

View file

@ -511,13 +511,14 @@ impl<'a> TextBuffer<'a> {
let end_glyph = if end.line == line_i_scrolled { let end_glyph = if end.line == line_i_scrolled {
end.glyph end.glyph
} else { } else {
line.glyphs.len() line.glyphs.len() + 1
}; };
if end_glyph > start_glyph {
let start_x = line.glyphs.get(start_glyph).map_or(0, |glyph| { let start_x = line.glyphs.get(start_glyph).map_or(0, |glyph| {
glyph.x as i32 glyph.x as i32
}); });
let end_x = line.glyphs.get(end_glyph).map_or(self.width, |glyph| { let end_x = line.glyphs.get(end_glyph - 1).map_or(self.width, |glyph| {
(glyph.x + glyph.w) as i32 (glyph.x + glyph.w) as i32
}); });
@ -530,6 +531,7 @@ impl<'a> TextBuffer<'a> {
); );
} }
} }
}
// Draw cursor // Draw cursor
if self.cursor.line == line_i_scrolled { if self.cursor.line == line_i_scrolled {