about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2024-09-01 01:20:35 -0700
committerKartik K. Agaram <vc@akkartik.com>2024-09-01 01:20:35 -0700
commita6008d4bebb952f5939399028d756ab243863c5f (patch)
tree6ef7853b597807c2977ee62c82d4ef646676de46
parentfcb69f5fb65016c1b4f56db4321e43949f75a901 (diff)
parentaf0d177d57978755f405404d1ebab21479e42ee9 (diff)
downloadview.love-a6008d4bebb952f5939399028d756ab243863c5f.tar.gz
Merge text.love
-rw-r--r--edit.lua2
-rw-r--r--source_edit.lua5
-rw-r--r--source_select.lua6
-rw-r--r--source_text.lua4
4 files changed, 9 insertions, 8 deletions
diff --git a/edit.lua b/edit.lua
index 7360304..8d47e86 100644
--- a/edit.lua
+++ b/edit.lua
@@ -240,7 +240,7 @@ function edit.keychord_press(State, chord, key)
       -- (we're not creating any ctrl-shift- or alt-shift- combinations using regular/printable keys)
       (not App.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 App.is_cursor_movement(key) then
-    Text.delete_selection(State, State.left, State.right)
+    Text.delete_selection_and_record_undo_event(State)
   end
   if State.search_term then
     if chord == 'escape' then
diff --git a/source_edit.lua b/source_edit.lua
index fead6c5..2dca05d 100644
--- a/source_edit.lua
+++ b/source_edit.lua
@@ -190,6 +190,7 @@ function edit.draw(State, hide_cursor, show_line_numbers)
                          State.cursor1.line = State.cursor1.line+1
                        end
                        record_undo_event(State, {before=Drawing.before, after=snapshot(State, line_index-1, line_index+1)})
+                       Drawing.before = nil
                        schedule_save(State)
                      end,
         })
@@ -391,7 +392,7 @@ function edit.keychord_press(State, chord, key)
       -- (we're not creating any ctrl-shift- or alt-shift- combinations using regular/printable keys)
       (not App.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 App.is_cursor_movement(key) then
-    Text.delete_selection(State, State.left, State.right)
+    Text.delete_selection_and_record_undo_event(State)
   end
   if State.search_term then
     if chord == 'escape' then
@@ -469,7 +470,7 @@ function edit.keychord_press(State, chord, key)
       App.set_clipboard(s)
     end
   elseif chord == 'C-x' then
-    local s = Text.cut_selection(State, State.left, State.right)
+    local s = Text.cut_selection_and_record_undo_event(State)
     if s then
       App.set_clipboard(s)
     end
diff --git a/source_select.lua b/source_select.lua
index b67dd16..a223b80 100644
--- a/source_select.lua
+++ b/source_select.lua
@@ -83,14 +83,14 @@ function Text.mouse_pos(State)
   return screen_bottom1.line, Text.pos_at_end_of_screen_line(State, screen_bottom1)
 end
 
-function Text.cut_selection(State)
+function Text.cut_selection_and_record_undo_event(State)
   if State.selection1.line == nil then return end
   local result = Text.selection(State)
-  Text.delete_selection(State)
+  Text.delete_selection_and_record_undo_event(State)
   return result
 end
 
-function Text.delete_selection(State)
+function Text.delete_selection_and_record_undo_event(State)
   if State.selection1.line == nil then return end
   local minl,maxl = minmax(State.selection1.line, State.cursor1.line)
   local before = snapshot(State, minl, maxl)
diff --git a/source_text.lua b/source_text.lua
index 76e9045..9125cb0 100644
--- a/source_text.lua
+++ b/source_text.lua
@@ -248,7 +248,7 @@ function Text.keychord_press(State, chord)
     schedule_save(State)
   elseif chord == 'backspace' then
     if State.selection1.line then
-      Text.delete_selection(State, State.left, State.right)
+      Text.delete_selection_and_record_undo_event(State)
       schedule_save(State)
       return
     end
@@ -296,7 +296,7 @@ function Text.keychord_press(State, chord)
     schedule_save(State)
   elseif chord == 'delete' then
     if State.selection1.line then
-      Text.delete_selection(State, State.left, State.right)
+      Text.delete_selection_and_record_undo_event(State)
       schedule_save(State)
       return
     end