Match cursor click behavior to other apps

This commit is contained in:
Jeremy Soller 2022-10-19 09:31:01 -06:00
parent e20552ad13
commit f03834e28d
No known key found for this signature in database
GPG key ID: 87F211AF2BE4C2FE

View file

@ -434,7 +434,12 @@ impl<'a> TextBuffer<'a> {
if mouse_x >= glyph.x as i32
&& mouse_x <= (glyph.x + glyph.w) as i32
{
new_cursor_glyph = glyph_i;
if mouse_x >= (glyph.x + glyph.w / 2.0) as i32 {
// If clicking on last half of glyph, move cursor past glyph
new_cursor_glyph = glyph_i + 1;
} else {
new_cursor_glyph = glyph_i;
}
}
}
new_cursor_opt = Some(TextCursor::new(new_cursor_line, new_cursor_glyph));