about summary refs log tree commit diff stats
path: root/undo.lua
diff options
context:
space:
mode:
Diffstat (limited to 'undo.lua')
-rw-r--r--undo.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/undo.lua b/undo.lua
index 873feea..a41ba38 100644
--- a/undo.lua
+++ b/undo.lua
@@ -36,11 +36,11 @@ end
 -- Make copies of objects; the rest of the app may mutate them in place, but undo requires immutable histories.
 function snapshot(State, s,e)
   -- Snapshot everything by default, but subset if requested.
-  assert(s)
+  assert(s, 'failed to snapshot operation for undo history')
   if e == nil then
     e = s
   end
-  assert(#State.lines > 0)
+  assert(#State.lines > 0, 'failed to snapshot operation for undo history')
   if s < 1 then s = 1 end
   if s > #State.lines then s = #State.lines end
   if e < 1 then e = 1 end
@@ -71,22 +71,22 @@ function patch(lines, from, to)
 --?     lines[from.start_line] = to.lines[1]
 --?     return
 --?   end
-  assert(from.start_line == to.start_line)
+  assert(from.start_line == to.start_line, 'failed to patch undo operation')
   for i=from.end_line,from.start_line,-1 do
     table.remove(lines, i)
   end
-  assert(#to.lines == to.end_line-to.start_line+1)
+  assert(#to.lines == to.end_line-to.start_line+1, 'failed to patch undo operation')
   for i=1,#to.lines do
     table.insert(lines, to.start_line+i-1, to.lines[i])
   end
 end
 
 function patch_placeholders(line_cache, from, to)
-  assert(from.start_line == to.start_line)
+  assert(from.start_line == to.start_line, 'failed to patch undo operation')
   for i=from.end_line,from.start_line,-1 do
     table.remove(line_cache, i)
   end
-  assert(#to.lines == to.end_line-to.start_line+1)
+  assert(#to.lines == to.end_line-to.start_line+1, 'failed to patch undo operation')
   for i=1,#to.lines do
     table.insert(line_cache, to.start_line+i-1, {})
   end