Used routine to add cursors in order correctly.

This commit is contained in:
Adam Harrison 2021-06-10 12:32:33 -04:00
parent 6915d86d59
commit dfc57bd884
2 changed files with 2 additions and 4 deletions

View File

@ -80,9 +80,7 @@ local function split_cursor(direction)
table.insert(new_cursors, { line1 + direction, col1 })
end
end
for i,v in ipairs(new_cursors) do
doc():set_selections(#doc().selections/4 + 1, v[1], v[2])
end
for i,v in ipairs(new_cursors) do doc():add_selection(v[1], v[2]) end
end
local commands = {

View File

@ -143,7 +143,7 @@ function Doc:set_selections(idx, line1, col1, line2, col2, swap, rm)
end
function Doc:add_selection(line1, col1, line2, col2, swap)
local l1, c1 = sort_positions(line1, col1, line2, col2)
local l1, c1 = sort_positions(line1, col1, line2 or line1, col2 or col1)
local target = #self.selections / 4 + 1
for idx, tl1, tc1 in self:get_selections(true) do
if l1 < tl1 or l1 == tl1 and c1 < tc1 then