Move cursor to the beginning or the end of its selection

When using `doc:move-to-{previous,next}-char` in a selection, we were 
moving the cursor to the character before the initial/after the last 
character of the selection.
Now we follow what other editors do and move it to just before the 
initial/just after the final character.
This commit is contained in:
Guldoman 2022-03-20 04:28:26 +01:00
parent b5ead3992e
commit 3765ef1d7a
No known key found for this signature in database
GPG Key ID: C08A498EC7F1AFDD
1 changed files with 4 additions and 2 deletions

View File

@ -578,18 +578,20 @@ commands["doc:move-to-previous-char"] = function()
for idx, line1, col1, line2, col2 in doc():get_selections(true) do
if line1 ~= line2 or col1 ~= col2 then
doc():set_selections(idx, line1, col1)
else
doc():move_to_cursor(idx, translate.previous_char)
end
end
doc():move_to(translate.previous_char)
end
commands["doc:move-to-next-char"] = function()
for idx, line1, col1, line2, col2 in doc():get_selections(true) do
if line1 ~= line2 or col1 ~= col2 then
doc():set_selections(idx, line2, col2)
else
doc():move_to_cursor(idx, translate.next_char)
end
end
doc():move_to(translate.next_char)
end
command.add("core.docview", commands)