mirror of
https://github.com/1j01/textual-paint.git
synced 2025-01-06 23:06:27 +03:00
Fix reloading file after losing color or character information
Can't use self.open_from_file_path because: 1. it short-circuits if the file is already open 2. it clears the undo history* 3. it does stuff with the backup file 4. plus it's not as efficient to use the FS, and it uses a callback, which is a pain. *TODO: make the reload undoable
This commit is contained in:
parent
3a3a554857
commit
17b4a67455
@ -2606,12 +2606,11 @@ class PaintApp(App[None]):
|
||||
self.saved_undo_count = len(self.undos)
|
||||
window.close()
|
||||
if reload_after_save:
|
||||
# Sigh... callbacks and coroutines
|
||||
def after_reload() -> None:
|
||||
saved_future.set_result(None)
|
||||
self.open_from_file_path(file_path, after_reload)
|
||||
else:
|
||||
saved_future.set_result(None)
|
||||
# TODO: 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)
|
||||
saved_future.set_result(None)
|
||||
|
||||
# TODO: should this look for a backup file and offer to recover it?
|
||||
# Seems kinda weird? But the backup file will be deleted on close,
|
||||
|
Loading…
Reference in New Issue
Block a user