Book: the page editor reloads after undo and redo

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
RobinFiredrake 2026-11-14 14:39:26 -06:00
parent a4688c1a4b
commit de942d57ee
3 changed files with 22 additions and 0 deletions

View file

@ -61,6 +61,17 @@ func _test_book() -> void:
main.undo_redo.undo()
await _frames()
_check(main.data.book.size() == 1, "undo brings the page back")
# Undo of a text edit shows in the open page editor at once.
var page := main.data.book[0]
main.book.editor.show_page(page)
var typed: TextEdit = main.book.editor.find_children("*", "TextEdit", true, false)[0]
typed.text = "Rusty Sword"
typed.text_changed.emit()
await _frames()
main.undo_redo.undo()
await _frames()
var shown: Array = main.book.editor.find_children("*", "TextEdit", true, false).map(func(edit: TextEdit) -> String: return edit.text)
_check(shown.has("Holy Sword"), "the page editor shows the undone text without reselecting: %s" % str(shown))
func _test_pictures() -> void:

View file

@ -89,6 +89,15 @@ func refresh() -> void:
editor.show_page(null)
## After undo or redo: the page in the editor is shown again from the
## restored spread, so its fields show the undone text at once.
func reload_page() -> void:
if editor == null or editor.page == null:
return
editor.show_page(m.data.get_page(editor.page.id))
refresh()
func set_width(px: float) -> void:
custom_minimum_size.x = px

View file

@ -210,6 +210,8 @@ func _apply_history(e: Dictionary, verb: String) -> void:
_keep_history = false
_restoring = false
m.local_state._sync_ledgers()
if m.book and m.book.visible:
m.book.reload_page()
m._board_changed()
m._refresh_lit()
m.tray.render()