diff --git a/data/core/doc/init.lua b/data/core/doc/init.lua index 6b880193..378f0896 100644 --- a/data/core/doc/init.lua +++ b/data/core/doc/init.lua @@ -251,11 +251,11 @@ local function pop_undo(self, undo_stack, redo_stack, modified) -- handle command if cmd.type == "insert" then 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 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 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 -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 local lines = split_lines(text) 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 self.highlighter:invalidate(line) self:sanitize_selection() - - if not quiet then - self:on_text_change("insert") - 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 local text = self:get_text(line1, col1, line2, col2) 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 self.highlighter:invalidate(line1) self:sanitize_selection() - - if not quiet then - self:on_text_change("remove") - end end function Doc:insert(line, col, text) self.redo_stack = { idx = 1 } 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 @@ -339,17 +332,18 @@ function Doc:remove(line1, col1, line2, col2) line1, col1 = self:sanitize_position(line1, col1) line2, col2 = self:sanitize_position(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 function Doc:undo() - pop_undo(self, self.undo_stack, self.redo_stack) + pop_undo(self, self.undo_stack, self.redo_stack, false) end function Doc:redo() - pop_undo(self, self.redo_stack, self.undo_stack) + pop_undo(self, self.redo_stack, self.undo_stack, false) end