From 0f229b039d6425ef9db6d9ffa8cd6c6c1eca3691 Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Thu, 10 Jun 2021 11:26:39 -0400 Subject: [PATCH] Fixed merging. Fixed selection undo stack. --- data/core/commands/doc.lua | 2 ++ data/core/doc/init.lua | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/data/core/commands/doc.lua b/data/core/commands/doc.lua index 0157962c..7644e11b 100644 --- a/data/core/commands/doc.lua +++ b/data/core/commands/doc.lua @@ -398,10 +398,12 @@ local commands = { ["doc:create-cursor-previous-line"] = function() split_cursor(-1) + doc():merge_cursors() end, ["doc:create-cursor-next-line"] = function() split_cursor(1) + doc():merge_cursors() end, } diff --git a/data/core/doc/init.lua b/data/core/doc/init.lua index 4c326f95..b9cfca5b 100644 --- a/data/core/doc/init.lua +++ b/data/core/doc/init.lua @@ -294,7 +294,7 @@ function Doc:raw_insert(line, col, text, undo_stack, time) -- push undo local line2, col2 = self:position_offset(line, col, #text) - push_undo(undo_stack, time, "selection", self:get_selection()) + push_undo(undo_stack, time, "selection", unpack(self.selections)) push_undo(undo_stack, time, "remove", line, col, line2, col2) -- update highlighter and assure selection is in bounds @@ -306,7 +306,7 @@ end 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()) + push_undo(undo_stack, time, "selection", unpack(self.selections)) push_undo(undo_stack, time, "insert", line1, col1, text) -- get line content before/after removed text