From 2f2eeff1ddc5250f8ea6ab52fa31a85e42247193 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 31 Aug 2024 19:01:33 -0700 Subject: [PATCH] explicitly state when operations manage undo --- edit.lua | 4 ++-- select.lua | 6 +++--- text.lua | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/edit.lua b/edit.lua index 749eb31..ad814da 100644 --- a/edit.lua +++ b/edit.lua @@ -361,7 +361,7 @@ function edit.keychord_press(editor, chord, key) -- (we're not creating any ctrl-shift- or alt-shift- combinations using regular/printable keys) (not shift_down() or utf8.len(key) == 1) and chord ~= 'C-a' and chord ~= 'C-c' and chord ~= 'C-x' and chord ~= 'backspace' and chord ~= 'delete' and chord ~= 'C-z' and chord ~= 'C-y' and not is_cursor_movement(key) then - Text.delete_selection(editor, editor.left, editor.right) + Text.delete_selection_and_record_undo_event(editor) end if editor.search_term then if chord == 'escape' then @@ -432,7 +432,7 @@ function edit.keychord_press(editor, chord, key) love.system.setClipboardText(s) end elseif chord == 'C-x' and cursor_on_screen then - local s = Text.cut_selection(editor, editor.left, editor.right) + local s = Text.cut_selection_and_record_undo_event(editor) if s then love.system.setClipboardText(s) end diff --git a/select.lua b/select.lua index 412506a..c699b81 100644 --- a/select.lua +++ b/select.lua @@ -5,14 +5,14 @@ function edit.mouse_loc(editor) return edit.to_loc(editor, mx, my) end -function Text.cut_selection(editor) +function Text.cut_selection_and_record_undo_event(editor) if editor.selection1.line == nil then return end local result = Text.selection(editor) - Text.delete_selection(editor) + Text.delete_selection_and_record_undo_event(editor) return result end -function Text.delete_selection(editor) +function Text.delete_selection_and_record_undo_event(editor) if editor.selection1.line == nil then return end local minl,maxl = minmax(editor.selection1.line, editor.cursor.line) local before = snapshot(editor, minl, maxl) diff --git a/text.lua b/text.lua index f36861a..c3812f3 100644 --- a/text.lua +++ b/text.lua @@ -54,7 +54,7 @@ function Text.keychord_press(editor, chord) elseif chord == 'backspace' then if editor.cursor.mode == 'text' then if editor.selection1.line then - Text.delete_selection(editor, editor.left, editor.right) + Text.delete_selection_and_record_undo_event(editor) schedule_save(editor) return end @@ -114,7 +114,7 @@ function Text.keychord_press(editor, chord) else -- cursor in text line if editor.selection1.line then - Text.delete_selection(editor, editor.left, editor.right) + Text.delete_selection_and_record_undo_event(editor) schedule_save(editor) return end