diff --git a/tests/test_book.gd b/tests/test_book.gd index 3056bf0..fe6fea0 100644 --- a/tests/test_book.gd +++ b/tests/test_book.gd @@ -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: diff --git a/ui/book_panel.gd b/ui/book_panel.gd index 061ba81..fc72acb 100644 --- a/ui/book_panel.gd +++ b/ui/book_panel.gd @@ -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 diff --git a/ui/main_history.gd b/ui/main_history.gd index 5bc2392..37d4c6e 100644 --- a/ui/main_history.gd +++ b/ui/main_history.gd @@ -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()