From 7f0c2818f26375540d1cda97d12697992cc8b00d Mon Sep 17 00:00:00 2001 From: aiongg Date: Sat, 14 Nov 2026 05:50:35 +0000 Subject: [PATCH] Place: closing a background document keeps the active document's place cursor --- crates/engine/src/lib.rs | 5 ++++- crates/engine/src/tests.rs | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 51e83f470..b535c2e78 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -608,7 +608,10 @@ impl Session { recovery::discard_document(self, i, recovery_dir.as_deref()); } if i < self.docs.len() { - self.unload_place_cursor(); + // A background document's closing leaves the active document's place cursor alone. + if self.active == Some(i) { + self.unload_place_cursor(); + } self.reset_find_scope(); self.docs.remove(i); self.active = if self.docs.is_empty() { None } else { Some(i.min(self.docs.len() - 1)) }; diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index f3b375403..08c30cdef 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -2558,6 +2558,17 @@ fn changing_documents_unloads_the_place_cursor_and_its_tool() { } } +/// Closing a background document leaves the active document's place cursor loaded. +#[test] +fn closing_a_background_document_keeps_the_place_cursor() { + let mut s = session(); + s.execute("file.new", &json!({})).unwrap(); + load_test_images(&mut s, 2); + s.close_document(0); + assert!(s.loaded.is_some() && s.loaded_queue.len() == 1); + assert_eq!(s.tool_id(), "placeGun"); +} + /// Issue #1637: with several objects selected, a click on one of them (no drag) makes it the key /// object, and Align to Key Object leaves it in place. A second click on it drops the key. #[test]