From e51ce129696320b729506a2c3f7c76bba402924e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 11 Jun 2022 20:47:04 -0700 Subject: bugfix: autosave and undo in a couple of cases This fixes part of #4, but not the BSOD. --- main.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'main.lua') diff --git a/main.lua b/main.lua index 83280ae..b3e0483 100644 --- a/main.lua +++ b/main.lua @@ -448,7 +448,11 @@ function App.keychord_pressed(chord) -- dispatch to drawing or text 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) elseif chord == 'escape' and love.mouse.isDown('1') then local _,drawing = Drawing.current_drawing() if drawing then @@ -465,6 +469,7 @@ function App.keychord_pressed(chord) Current_drawing_mode = Previous_drawing_mode Previous_drawing_mode = nil else + local before = snapshot(Lines.current_drawing_index) local drawing = Lines.current_drawing local p = drawing.points[drawing.pending.target_point] if chord == 'escape' then @@ -474,6 +479,7 @@ function App.keychord_pressed(chord) local byte_offset = utf8.offset(p.name, len-1) p.name = string.sub(p.name, 1, byte_offset) end + record_undo_event({before=before, after=snapshot(Lines.current_drawing_index)}) end save_to_disk(Lines, Filename) else -- cgit 1.4.1-2-gfad0