Merge pull request #465 from adamharrison/fix-multicursor-commands

Forgot to return an 'n'.
This commit is contained in:
Adam 2021-08-31 16:23:17 -04:00 committed by GitHub
commit 06b64f2928
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -479,17 +479,18 @@ function Doc:replace_cursor(idx, line1, col1, line2, col2, fn)
end end
function Doc:replace(fn) function Doc:replace(fn)
local has_selection = false local has_selection, n = false, 0
for idx, line1, col1, line2, col2 in self:get_selections(true) do for idx, line1, col1, line2, col2 in self:get_selections(true) do
if line1 ~= line2 or col1 ~= col2 then if line1 ~= line2 or col1 ~= col2 then
self:replace_cursor(idx, line1, col1, line2, col2, fn) n = n + self:replace_cursor(idx, line1, col1, line2, col2, fn)
has_selection = true has_selection = true
end end
end end
if not has_selection then if not has_selection then
self:set_selection(table.unpack(self.selections)) self:set_selection(table.unpack(self.selections))
self:replace_cursor(1, 1, 1, #self.lines, #self.lines[#self.lines], fn) n = n + self:replace_cursor(1, 1, 1, #self.lines, #self.lines[#self.lines], fn)
end end
return n
end end