diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index fba8eb6ee3..8ad7a9f932 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -1214,6 +1214,10 @@ impl DocView { if self.select_anchor.is_some_and(|a| a > last) { self.select_anchor = None; } + // A Snapshot area names a page by its index and a rectangle on it: after pages were + // deleted or moved it would outline, print and save a different page. + self.area_pick = None; + self.area_choice = None; self.goto = None; self.goto_point = None; self.zoom_anchor = None; diff --git a/crates/ui-egui/tests/it/snapshot_area_tabs.rs b/crates/ui-egui/tests/it/snapshot_area_tabs.rs index b6dd497f6b..5b4e450036 100644 --- a/crates/ui-egui/tests/it/snapshot_area_tabs.rs +++ b/crates/ui-egui/tests/it/snapshot_area_tabs.rs @@ -71,3 +71,13 @@ fn leaving_snapshot_clears_every_tab() { assert!(h.state().views[1].area_pick.is_none(), "the tab on screen"); assert!(h.state().views[0].area_pick.is_none(), "the other tab"); } + +/// A change to the page list leaves no area behind: its page index would name another page. +#[test] +fn a_document_change_puts_the_area_away() { + let mut h = harness(); + h.state_mut().views[0].area_pick = Some((0, [10.0, 130.0, 150.0, 170.0])); + let info = h.state().session.get(h.state().views[0].id).unwrap().info.clone(); + h.state_mut().views[0].document_changed(&info); + assert!(h.state().views[0].area_pick.is_none()); +}