From ba59df768b0d7221e6480acf38c71e5ab3708072 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 24 Oct 2026 13:40:54 -0700 Subject: [PATCH] Edit Points: a panic after a change of document leaves no point type The guard put back the remembered point type after a panic even when the command had made another document active, so the type of a shape in the first document applied to a shape with the same id in the second. The guard now puts it back only when the document from before is still active, and forgets it otherwise. --- crates/engine/src/guard.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/guard.rs b/crates/engine/src/guard.rs index 21cf1f8a..1005a1a9 100644 --- a/crates/engine/src/guard.rs +++ b/crates/engine/src/guard.rs @@ -42,7 +42,9 @@ impl Session { Ok(r) => r, Err(payload) => { self.depth = depth; - self.tool.vertex_kind = vertex_kind; + // The remembered point type names a shape of the document it was chosen in. + let same = before.as_ref().is_some_and(|b| self.active().is_some_and(|st| st.uid == b.0)); + self.tool.vertex_kind = if same { vertex_kind } else { None }; let msg = panic_message(payload.as_ref()); // Keep the document as it was before the command. if let (Some((uid, doc, selection, revision)), Some(st)) = (before, self.active_mut()) @@ -105,6 +107,15 @@ mod tests { }); assert!(r.is_err()); assert_eq!(s.tool.vertex_kind, kept); + // A command that opens another document and then panics leaves no point type behind: the + // one from before names a shape of the other document. + let r = s.guarded("test.panic", |s| { + s.execute("file.new", &json!({}))?; + s.tool.vertex_kind = Some((deckcraft_model::ShapeId(1), 0, 0, "corner".to_string())); + panic!("boom"); + }); + assert!(r.is_err()); + assert_eq!(s.tool.vertex_kind, None); } #[test]