From 2ed803631bd40309930d3f494b491b9f4db4d33c Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Mon, 12 Jun 2023 01:49:11 -0400 Subject: [PATCH] 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. --- cspell.json | 1 + src/textual_paint/paint.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cspell.json b/cspell.json index 34b1fc9..1c8c738 100644 --- a/cspell.json +++ b/cspell.json @@ -45,6 +45,7 @@ "getpixel", "goland", "gvim", + "hackily", "Haha", "hkey", "hslrgb", diff --git a/src/textual_paint/paint.py b/src/textual_paint/paint.py index e8319d5..48b01b8 100755 --- a/src/textual_paint/paint.py +++ b/src/textual_paint/paint.py @@ -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