bugfix: undo drawing creation

Also clean up drawing state to make sure we don't get into hard-to-debug
situations.
This commit is contained in:
Kartik K. Agaram 2022-06-02 15:51:44 -07:00
parent 670886240f
commit b4e76eac4e
2 changed files with 5 additions and 1 deletions

View File

@ -348,7 +348,10 @@ function Drawing.mouse_released(x,y, button)
end
end
save_to_disk(Lines, Filename)
record_undo_event({before=Drawing.before, after=snapshot_everything()})
if Drawing.before then
record_undo_event({before=Drawing.before, after=snapshot_everything()})
Drawing.before = nil
end
end
function Drawing.keychord_pressed(chord)

View File

@ -142,6 +142,7 @@ function App.draw()
button('draw', {x=4,y=y+4, w=12,h=12, color={1,1,0},
icon = icon.insert_drawing,
onpress1 = function()
Drawing.before = snapshot_everything()
table.insert(Lines, line_index, {mode='drawing', y=y, h=256/2, points={}, shapes={}, pending={}})
if Cursor1.line >= line_index then
Cursor1.line = Cursor1.line+1