about summary refs log tree commit diff stats
path: root/text.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-05-25 15:08:37 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-05-25 15:08:53 -0700
commit1fa295e59969613c8ef9798293cc9b8708c8d6dc (patch)
tree8cc03145f3eaa438f11029b65cfbd19ae0444868 /text.lua
parent815c4f010a9cba64c4508490b763abd337a8a5a8 (diff)
downloadlines.love-1fa295e59969613c8ef9798293cc9b8708c8d6dc.tar.gz
keep repeated cursor up/down motions from drifting left
Diffstat (limited to 'text.lua')
-rw-r--r--text.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/text.lua b/text.lua
index 626e898..eba0d4b 100644
--- a/text.lua
+++ b/text.lua
@@ -1108,7 +1108,11 @@ function Text.nearest_cursor_pos(line, x)  -- x includes left margin
     local currxmax = Text.cursor_x(line, curr+1)
 --?     print('nearest', x, left, right, curr, currxmin, currxmax)
     if currxmin <= x and x < currxmax then
-      return curr
+      if x-currxmin < currxmax-x then
+        return curr
+      else
+        return curr+1
+      end
     end
     if left >= right-1 then
       return right