Simplifies previous commit
Restore the previous signature of raw_insert/remove
This commit is contained in:
parent
d1984942ea
commit
e43c980e4a
|
@ -251,11 +251,11 @@ local function pop_undo(self, undo_stack, redo_stack, modified)
|
||||||
-- handle command
|
-- handle command
|
||||||
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, true)
|
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, true)
|
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.selection.a.line, self.selection.a.col = cmd[1], cmd[2]
|
||||||
|
@ -275,7 +275,7 @@ local function pop_undo(self, undo_stack, redo_stack, modified)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function Doc:raw_insert(line, col, text, undo_stack, time, quiet)
|
function Doc:raw_insert(line, col, text, undo_stack, time)
|
||||||
-- split text into lines and merge with line at insertion point
|
-- split text into lines and merge with line at insertion point
|
||||||
local lines = split_lines(text)
|
local lines = split_lines(text)
|
||||||
local before = self.lines[line]:sub(1, col - 1)
|
local before = self.lines[line]:sub(1, col - 1)
|
||||||
|
@ -297,14 +297,10 @@ function Doc:raw_insert(line, col, text, undo_stack, time, quiet)
|
||||||
-- update highlighter and assure selection is in bounds
|
-- update highlighter and assure selection is in bounds
|
||||||
self.highlighter:invalidate(line)
|
self.highlighter:invalidate(line)
|
||||||
self:sanitize_selection()
|
self:sanitize_selection()
|
||||||
|
|
||||||
if not quiet then
|
|
||||||
self:on_text_change("insert")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function Doc:raw_remove(line1, col1, line2, col2, undo_stack, time, quiet)
|
function Doc:raw_remove(line1, col1, line2, col2, undo_stack, time)
|
||||||
-- push undo
|
-- push undo
|
||||||
local text = self:get_text(line1, col1, line2, col2)
|
local text = self:get_text(line1, col1, line2, col2)
|
||||||
push_undo(undo_stack, time, "selection", self:get_selection())
|
push_undo(undo_stack, time, "selection", self:get_selection())
|
||||||
|
@ -320,17 +316,14 @@ function Doc:raw_remove(line1, col1, line2, col2, undo_stack, time, quiet)
|
||||||
-- update highlighter and assure selection is in bounds
|
-- update highlighter and assure selection is in bounds
|
||||||
self.highlighter:invalidate(line1)
|
self.highlighter:invalidate(line1)
|
||||||
self:sanitize_selection()
|
self:sanitize_selection()
|
||||||
|
|
||||||
if not quiet then
|
|
||||||
self:on_text_change("remove")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function Doc:insert(line, col, text)
|
function Doc:insert(line, col, text)
|
||||||
self.redo_stack = { idx = 1 }
|
self.redo_stack = { idx = 1 }
|
||||||
line, col = self:sanitize_position(line, col)
|
line, col = self:sanitize_position(line, col)
|
||||||
self:raw_insert(line, col, text, self.undo_stack, system.get_time(), false)
|
self:raw_insert(line, col, text, self.undo_stack, system.get_time())
|
||||||
|
self:on_text_change("insert")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -339,17 +332,18 @@ function Doc:remove(line1, col1, line2, col2)
|
||||||
line1, col1 = self:sanitize_position(line1, col1)
|
line1, col1 = self:sanitize_position(line1, col1)
|
||||||
line2, col2 = self:sanitize_position(line2, col2)
|
line2, col2 = self:sanitize_position(line2, col2)
|
||||||
line1, col1, line2, col2 = sort_positions(line1, col1, line2, col2)
|
line1, col1, line2, col2 = sort_positions(line1, col1, line2, col2)
|
||||||
self:raw_remove(line1, col1, line2, col2, self.undo_stack, system.get_time(), false)
|
self:raw_remove(line1, col1, line2, col2, self.undo_stack, system.get_time())
|
||||||
|
self:on_text_change("remove")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function Doc:undo()
|
function Doc:undo()
|
||||||
pop_undo(self, self.undo_stack, self.redo_stack)
|
pop_undo(self, self.undo_stack, self.redo_stack, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function Doc:redo()
|
function Doc:redo()
|
||||||
pop_undo(self, self.redo_stack, self.undo_stack)
|
pop_undo(self, self.redo_stack, self.undo_stack, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue