Fixed undo stack.
This commit is contained in:
parent
93670a314d
commit
a7f39017ff
|
@ -159,9 +159,16 @@ end
|
||||||
|
|
||||||
function Doc:get_selection(sort)
|
function Doc:get_selection(sort)
|
||||||
if sort then
|
if sort then
|
||||||
return sort_positions(self.selections[1], self.selections[2], self.selections[3], self.selections[4])
|
local result = {}
|
||||||
|
for sidx, line1, col1, line2, col2 in self:get_selections(true) do
|
||||||
|
table.insert(result, line1)
|
||||||
|
table.insert(result, col1)
|
||||||
|
table.insert(result, line2)
|
||||||
|
table.insert(result, col2)
|
||||||
|
end
|
||||||
|
return result
|
||||||
end
|
end
|
||||||
return self.selections[1], self.selections[2], self.selections[3], self.selections[4]
|
return unpack(self.selections)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Doc:get_selection_count()
|
function Doc:get_selection_count()
|
||||||
|
@ -292,14 +299,11 @@ local function pop_undo(self, undo_stack, redo_stack, modified)
|
||||||
if cmd.type == "insert" then
|
if cmd.type == "insert" then
|
||||||
local line, col, text = table.unpack(cmd)
|
local line, col, text = table.unpack(cmd)
|
||||||
self:raw_insert(line, col, text, redo_stack, cmd.time)
|
self:raw_insert(line, col, text, redo_stack, cmd.time)
|
||||||
|
|
||||||
elseif cmd.type == "remove" then
|
elseif cmd.type == "remove" then
|
||||||
local line1, col1, line2, col2 = table.unpack(cmd)
|
local line1, col1, line2, col2 = table.unpack(cmd)
|
||||||
self:raw_remove(line1, col1, line2, col2, redo_stack, cmd.time)
|
self:raw_remove(line1, col1, line2, col2, redo_stack, cmd.time)
|
||||||
|
|
||||||
elseif cmd.type == "selection" then
|
elseif cmd.type == "selection" then
|
||||||
self.selection.a.line, self.selection.a.col = cmd[1], cmd[2]
|
self.selections = { unpack(cmd) }
|
||||||
self.selection.b.line, self.selection.b.col = cmd[3], cmd[4]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
modified = modified or (cmd.type ~= "selection")
|
modified = modified or (cmd.type ~= "selection")
|
||||||
|
|
|
@ -278,12 +278,11 @@ function DocView:on_mouse_moved(x, y, ...)
|
||||||
local clicks = self.mouse_selecting.clicks
|
local clicks = self.mouse_selecting.clicks
|
||||||
if keymap.modkeys["ctrl"] then
|
if keymap.modkeys["ctrl"] then
|
||||||
if l1 > l2 then
|
if l1 > l2 then
|
||||||
l2 = l1
|
l1, l2 = l2, l1
|
||||||
end
|
end
|
||||||
local idx = 1
|
local idx = 1
|
||||||
for i = l1, l2 do
|
for i = l1, l2 do
|
||||||
idx = idx + 1
|
self.doc:set_selections(i - l1 + 1, i, math.min(c1, #self.doc.lines[i]), i, math.min(c1, #self.doc.lines[i]))
|
||||||
self.doc:set_selections(idx, i, math.min(c1, #self.doc.lines[i]), i, math.min(c1, #self.doc.lines[i]))
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.doc:set_selection(mouse_selection(self.doc, clicks, l1, c1, l2, c2))
|
self.doc:set_selection(mouse_selection(self.doc, clicks, l1, c1, l2, c2))
|
||||||
|
|
Loading…
Reference in New Issue