keep repeated cursor up/down motions from drifting left

This commit is contained in:
Kartik K. Agaram 2022-05-25 15:08:37 -07:00
parent 815c4f010a
commit 1fa295e599
1 changed files with 5 additions and 1 deletions

View File

@ -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