From 5800acceac4c808c5fde1da0dc2ef06026439279 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sun, 12 Mar 2023 22:59:39 +0100 Subject: [PATCH] Consider glyph side when determining cursor position --- src/ide/jump.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ide/jump.rs b/src/ide/jump.rs index 8a19c1fde..033d0f7fa 100644 --- a/src/ide/jump.rs +++ b/src/ide/jump.rs @@ -40,7 +40,11 @@ pub fn jump_from_click(world: &dyn World, frame: &Frame, click: Point) -> Option let node = source.find(glyph.span); let pos = if node.kind() == SyntaxKind::Text { let range = node.range(); - (range.start + usize::from(glyph.offset)).min(range.end) + let mut offset = range.start + usize::from(glyph.offset); + if (click.x - pos.x) > width / 2.0 { + offset += glyph.c.len_utf8(); + } + offset.min(range.end) } else { node.offset() };