Merge pull request #1070 from Guldoman/PR_get_selections_swap_return

Make `Doc:get_selection[s]` return if the selection was actually sorted
This commit is contained in:
Jefferson González 2022-07-13 11:13:43 -04:00 committed by GitHub
commit 86d45458f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -146,8 +146,8 @@ end
-- curors can never swap positions; only merge or split, or change their position in cursor
-- order.
function Doc:get_selection(sort)
local idx, line1, col1, line2, col2 = self:get_selections(sort)({ self.selections, sort }, 0)
return line1, col1, line2, col2, sort
local idx, line1, col1, line2, col2, swap = self:get_selections(sort)({ self.selections, sort }, 0)
return line1, col1, line2, col2, swap
end
function Doc:get_selection_text(limit)
@ -183,9 +183,9 @@ end
local function sort_positions(line1, col1, line2, col2)
if line1 > line2 or line1 == line2 and col1 > col2 then
return line2, col2, line1, col1
return line2, col2, line1, col1, true
end
return line1, col1, line2, col2
return line1, col1, line2, col2, false
end
function Doc:set_selections(idx, line1, col1, line2, col2, swap, rm)