Allow undoing color or character information loss

Of course, this highlights the need to prompt during Save as well,
not just Save As, or to make creating color or character information
impossible depending on the type of file that is open.
This commit is contained in:
Isaiah Odhner 2023-06-12 01:49:11 -04:00
parent 17b4a67455
commit 2ed803631b
2 changed files with 3 additions and 2 deletions

View File

@ -45,6 +45,7 @@
"getpixel",
"goland",
"gvim",
"hackily",
"Haha",
"hkey",
"hslrgb",

View File

@ -2606,7 +2606,7 @@ class PaintApp(App[None]):
self.saved_undo_count = len(self.undos)
window.close()
if reload_after_save:
# TODO: make this undoable
self.resize_document(self.image.width, self.image.height) # (hackily) make this undoable
new_image = AnsiArtDocument.decode_based_on_file_extension(content, file_path)
self.canvas.image = self.image = new_image
self.canvas.refresh(layout=True)
@ -3269,7 +3269,7 @@ class PaintApp(App[None]):
self.cancel_preview()
# NOTE: This function is relied on to create an undo even if the size doesn't change,
# when recovering from a backup.
# when recovering from a backup, and when reloading file content when losing information during Save As.
# TODO: DRY undo state creation (at least the undos/redos part)
action = Action(_("Attributes"), Region(0, 0, self.image.width, self.image.height))
action.is_resize = True