Merge pull request #3203 from rahul05ranjan/fix/offset-path-preview-memory

Offset Path's Preview checkbox keeps its last state across opens (#3195)
This commit is contained in:
BFlat
2026-10-21 15:41:23 +07:00
committed by GitHub
2 changed files with 18 additions and 1 deletions
+3 -1
View File
@@ -193,7 +193,9 @@ fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result<Value, String> {
}
// The fields as the dialog held them, so they show as typed when it opens again.
if d.kind == "offsetPath" {
let kept = ["offset", "joins", "miterLimit"].into_iter().filter_map(|k| Some((k.to_string(), d.fields.get(k)?.clone())));
// Preview among them: the checkbox keeps its last state across opens (#3195), as
// Simplify's retained fields keep theirs.
let kept = ["offset", "joins", "miterLimit", "preview"].into_iter().filter_map(|k| Some((k.to_string(), d.fields.get(k)?.clone())));
app.ui.offset_path = Value::Object(kept.collect());
}
Ok(r)
+15
View File
@@ -284,6 +284,21 @@ fn offset_path_remembers_its_last_values() {
assert_eq!((d.f64("offset", 0.0), d.str("joins"), d.f64("miterLimit", 0.0)), (-4.5, "round".to_string(), 4.0));
}
/// Offset Path's Preview checkbox keeps its last state across opens, like the other fields (#3195).
#[test]
fn offset_path_remembers_its_last_preview_state() {
let mut app = app_with_selection();
app.run("select.all", json!({})).unwrap();
crate::menus::invoke(&mut app, "object.path.offsetPath", json!({}));
let d = app.ui.dialog.as_mut().unwrap();
assert!(!d.bool("preview"), "a first open is unchecked");
d.fields.insert("preview".into(), json!(true));
confirm(&mut app).unwrap();
crate::menus::invoke(&mut app, "object.path.offsetPath", json!({}));
let d = app.ui.dialog.as_ref().unwrap();
assert!(d.bool("preview"), "the state it was confirmed with");
}
fn app_with_dense_path() -> VectorcraftApp {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();