Merge pull request #9524 from dotCooCoo/fix/expand-source-drawing

Keep Expand attached to its original drawing
This commit is contained in:
BFlat authored and GitHub committed 2026-11-27 07:28:35 +07:00
commit d84572cd7c
1 file changed
+26 -1
+26 -1
View File
@@ -154,7 +154,14 @@ fn dialog(app: &VectorcraftApp, info: ExpandInfo) -> Result<HostedParamDialog, S
/// Shows `dialog`; its OK expands.
fn show(app: &mut VectorcraftApp, dialog: HostedParamDialog) -> Result<Value, String> {
crate::dialogs::host::open_held(app, dialog, ok).ok_or("no window")?;
let document = app.session.active().ok_or("no document open")?.uid;
crate::dialogs::host::open_held(app, dialog, move |app, result: &ParamResult| {
if app.session.active().is_none_or(|st| st.uid != document) {
return Err(tl!("Return to the original drawing to expand the artwork").into());
}
ok(app, result)
})
.ok_or("no window")?;
Ok(Value::Null)
}
@@ -285,6 +292,24 @@ mod tests {
assert!(matches!(children[1].kind, NodeKind::Mesh(_)));
}
#[test]
fn expand_keeps_its_draft_when_another_drawing_is_active() {
let mut app = app();
gradient_rectangle(&mut app);
open(&mut app).unwrap();
set(&app, "gradient", json!("mesh")).unwrap();
gradient_rectangle(&mut app);
let undo = app.session.active().unwrap().history.undo.len();
let before = app.session.active().unwrap().doc.clone();
assert!(matches!(press_ok(&mut app), Some(HeldOk::Refused(reason)) if reason.as_str().contains("original drawing")));
assert_eq!(app.session.active().unwrap().history.undo.len(), undo);
assert!(std::sync::Arc::ptr_eq(&app.session.active().unwrap().doc, &before));
assert_eq!(fields(&app).text("gradient"), Some("mesh"));
app.run("document.activate", json!({"index": 0})).unwrap();
ok_and_close(&mut app);
assert!(expanded_to_a_mesh(&app));
}
#[test]
fn expand_gradient_to_is_disabled_for_a_pattern_fill_alone() {
let mut app = app();