about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--source_undo.lua10
-rw-r--r--undo.lua10
2 files changed, 2 insertions, 18 deletions
diff --git a/source_undo.lua b/source_undo.lua
index e5dea93..8f21a9c 100644
--- a/source_undo.lua
+++ b/source_undo.lua
@@ -57,16 +57,8 @@ function snapshot(State, s,e)
     end_line=e,
     -- no filename; undo history is cleared when filename changes
   }
-  -- deep copy lines without cached stuff like text fragments
   for i=s,e do
-    local line = State.lines[i]
-    if line.mode == 'text' then
-      table.insert(event.lines, {mode='text', data=line.data})  -- I've forgotten: should we deepcopy(line.data)?
-    elseif line.mode == 'drawing' then
-      table.insert(event.lines, {mode='drawing', h=line.h, points=deepcopy(line.points), shapes=deepcopy(line.shapes), pending={}})
-    else
-      assert(false, ('unknown line mode %s'):format(line.mode))
-    end
+    table.insert(event.lines, deepcopy(State.lines[i]))
   end
   return event
 end
diff --git a/undo.lua b/undo.lua
index e5dea93..8f21a9c 100644
--- a/undo.lua
+++ b/undo.lua
@@ -57,16 +57,8 @@ function snapshot(State, s,e)
     end_line=e,
     -- no filename; undo history is cleared when filename changes
   }
-  -- deep copy lines without cached stuff like text fragments
   for i=s,e do
-    local line = State.lines[i]
-    if line.mode == 'text' then
-      table.insert(event.lines, {mode='text', data=line.data})  -- I've forgotten: should we deepcopy(line.data)?
-    elseif line.mode == 'drawing' then
-      table.insert(event.lines, {mode='drawing', h=line.h, points=deepcopy(line.points), shapes=deepcopy(line.shapes), pending={}})
-    else
-      assert(false, ('unknown line mode %s'):format(line.mode))
-    end
+    table.insert(event.lines, deepcopy(State.lines[i]))
   end
   return event
 end