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:
parent
b5ead3992e
commit
3765ef1d7a
|
@ -578,18 +578,20 @@ commands["doc:move-to-previous-char"] = function()
|
||||||
for idx, line1, col1, line2, col2 in doc():get_selections(true) do
|
for idx, line1, col1, line2, col2 in doc():get_selections(true) do
|
||||||
if line1 ~= line2 or col1 ~= col2 then
|
if line1 ~= line2 or col1 ~= col2 then
|
||||||
doc():set_selections(idx, line1, col1)
|
doc():set_selections(idx, line1, col1)
|
||||||
|
else
|
||||||
|
doc():move_to_cursor(idx, translate.previous_char)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
doc():move_to(translate.previous_char)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
commands["doc:move-to-next-char"] = function()
|
commands["doc:move-to-next-char"] = function()
|
||||||
for idx, line1, col1, line2, col2 in doc():get_selections(true) do
|
for idx, line1, col1, line2, col2 in doc():get_selections(true) do
|
||||||
if line1 ~= line2 or col1 ~= col2 then
|
if line1 ~= line2 or col1 ~= col2 then
|
||||||
doc():set_selections(idx, line2, col2)
|
doc():set_selections(idx, line2, col2)
|
||||||
|
else
|
||||||
|
doc():move_to_cursor(idx, translate.next_char)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
doc():move_to(translate.next_char)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
command.add("core.docview", commands)
|
command.add("core.docview", commands)
|
||||||
|
|
Loading…
Reference in New Issue