summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-03-12 22:59:39 +0100
committerLaurenz <laurmaedje@gmail.com>2023-03-12 22:59:39 +0100
commit5800acceac4c808c5fde1da0dc2ef06026439279 (patch)
tree8019521af263e14f7cbf57ae909f8a1c6ddfdeaf
parenta735bb9db3fa57c48fd02f98bdd93f0879cc4eb1 (diff)
Consider glyph side when determining cursor position
-rw-r--r--src/ide/jump.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ide/jump.rs b/src/ide/jump.rs
index 8a19c1fd..033d0f7f 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()
};