about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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
6'>66 67 68 69 70 71 72 73 74 75 76 77 78 79