about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--main.lua10
1 files changed, 6 insertions, 4 deletions
diff --git a/main.lua b/main.lua
index e3d2ef4..98d2707 100644
--- a/main.lua
+++ b/main.lua
@@ -449,10 +449,12 @@ function App.keychord_pressed(chord)
   elseif love.mouse.isDown('1') or chord:sub(1,2) == 'C-' then
     -- DON'T reset line.y here
     local drawing_index, drawing = Drawing.current_drawing()
-    local before = snapshot(drawing_index)
-    Drawing.keychord_pressed(chord)
-    record_undo_event({before=before, after=snapshot(drawing_index)})
-    save_to_disk(Lines, Filename)
+    if drawing_index then
+      local before = snapshot(drawing_index)
+      Drawing.keychord_pressed(chord)
+      record_undo_event({before=before, after=snapshot(drawing_index)})
+      save_to_disk(Lines, Filename)
+    end
   elseif chord == 'escape' and love.mouse.isDown('1') then
     local _,drawing = Drawing.current_drawing()
     if drawing then