Merge pull request #886 from adamharrison/fix-left-click-issues
Fixed a bunch of problems relating to multicursor.
This commit is contained in:
commit
0e323f4a35
|
@ -175,14 +175,12 @@ local function block_comment(comment, line1, col1, line2, col2)
|
|||
end
|
||||
end
|
||||
|
||||
local selection_commands = {
|
||||
local commands = {
|
||||
["doc:select-none"] = function()
|
||||
local line, col = doc():get_selection()
|
||||
doc():set_selection(line, col)
|
||||
end
|
||||
}
|
||||
end,
|
||||
|
||||
local commands = {
|
||||
["doc:cut"] = function()
|
||||
cut_or_copy(true)
|
||||
end,
|
||||
|
@ -523,7 +521,18 @@ local commands = {
|
|||
|
||||
["doc:split-cursor"] = function(x, y, clicks)
|
||||
local line, col = dv():resolve_screen_position(x, y)
|
||||
doc():add_selection(line, col, line, col)
|
||||
local removal_target = nil
|
||||
for idx, line1, col1 in doc():get_selections(true) do
|
||||
if line1 == line and col1 == col and #doc().selections > 4 then
|
||||
removal_target = idx
|
||||
end
|
||||
end
|
||||
if removal_target then
|
||||
doc():remove_selection(removal_target)
|
||||
else
|
||||
doc():add_selection(line, col, line, col)
|
||||
end
|
||||
dv().mouse_selecting = { line, col, "set" }
|
||||
end,
|
||||
|
||||
["doc:create-cursor-previous-line"] = function()
|
||||
|
@ -584,6 +593,3 @@ commands["doc:move-to-next-char"] = function()
|
|||
end
|
||||
|
||||
command.add("core.docview", commands)
|
||||
command.add(function()
|
||||
return core.active_view:is(DocView) and core.active_view.doc:has_any_selection()
|
||||
end ,selection_commands)
|
||||
|
|
|
@ -198,6 +198,12 @@ function Doc:add_selection(line1, col1, line2, col2, swap)
|
|||
self:set_selections(target, line1, col1, line2, col2, swap, 0)
|
||||
end
|
||||
|
||||
|
||||
function Doc:remove_selection(idx)
|
||||
common.splice(self.selections, (idx - 1) * 4 + 1, 4)
|
||||
end
|
||||
|
||||
|
||||
function Doc:set_selection(line1, col1, line2, col2, swap)
|
||||
self.selections = {}
|
||||
self:set_selections(1, line1, col1, line2, col2, swap)
|
||||
|
|
|
@ -224,7 +224,6 @@ function DocView:scroll_to_make_visible(line, col)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
function DocView:on_mouse_moved(x, y, ...)
|
||||
DocView.super.on_mouse_moved(self, x, y, ...)
|
||||
|
||||
|
|
Loading…
Reference in New Issue