scenario:
  start with an empty file, there's one line with a '+' button on it
  press the '+' to create a drawing in the top line
  press C-z to undo
  = before this commit, undo would create a weird intermediate state where there were two lines with '+' on them

scenario:
  type something into the first line, press enter to append a second line
  press the '+' on the second line to create a drawing
  press C-z to undo
  = crash

The root cause in both cases: we end up creating 2 undo events starting
from the same before snapshot: one inside the button handler, and a
second on mouse release.

This doesn't affect lines 1 because we had a separate variable called
current_drawing which protected the mouse release handler from
triggering.
This commit is contained in:
Kartik K. Agaram 2024-08-31 18:28:48 -07:00
parent 73f5b9632f
commit cd34c94a4a
1 changed files with 1 additions and 0 deletions

View File

@ -162,6 +162,7 @@ function edit.draw(Editor)
end
schedule_save(Editor)
record_undo_event(Editor, {before=Editor.drawing_before, after=snapshot(Editor, line_index-1, line_index+1)})
Editor.drawing_before = nil
end,
})
else