From f03834e28d4e807e56c57ca9ef97ae25f168f835 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 19 Oct 2022 09:31:01 -0600 Subject: [PATCH] Match cursor click behavior to other apps --- src/buffer.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/buffer.rs b/src/buffer.rs index c283b41..7c853d3 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -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));