Retire Simplify and Smooth strips after File Revert (#9646)

This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-26 22:24:45 -05:00
1 parent 0aea8fed95
commit f3100589b0
2 files changed
+36 -3

No files matched your search

@@ -86,7 +86,7 @@ pub(crate) struct Strip {
/// Which command the strip previews.
pub kind: StripKind,
/// The drawing whose selection and preview the strip uses.
document: Option<u64>,
document: Option<(u64, u64)>,
/// The slider's value, 0 to 100.
pub level: f64,
/// The selection's document bounds when the strip opened, so the strip stays put while the
@@ -102,7 +102,7 @@ pub(crate) struct Strip {
impl Strip {
fn in_source(&self, app: &VectorcraftApp) -> bool {
self.document == app.session.active().map(|doc| doc.uid)
self.document == app.session.active().map(|doc| (doc.uid, doc.reverts))
}
fn cancel(self, app: &mut VectorcraftApp) {
@@ -142,7 +142,7 @@ pub(crate) fn open(app: &mut VectorcraftApp, kind: StripKind) {
}
let strip = Strip {
kind,
document: app.session.active().map(|doc| doc.uid),
document: app.session.active().map(|doc| (doc.uid, doc.reverts)),
level: opening_level(app, kind),
bounds: app.selection_bounds(),
open: true,
+33
View File
@@ -293,3 +293,36 @@ fn simplify_slider_and_dialog_simplify_only_the_direct_selected_part_of_a_path()
assert_eq!(app.session.doc().unwrap().history.undo.len(), undo_len + 1);
kept(&app, "the dialog");
}
#[test]
fn path_sliders_close_when_file_revert_restores_the_artwork() {
for (kind, command) in
[(simplify_slider::StripKind::Simplify, "object.path.simplify"), (simplify_slider::StripKind::Smooth, "object.path.smooth")]
{
let mut app = app_with_dense_path();
let id = app.session.active().unwrap().selection.objects[0];
let dir = vectorcraft_testkit::TempDir::new("path-slider-revert");
app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string())));
app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string())));
app.run("file.saveAs", json!({"path": dir.join("Art.vectorcraft")})).unwrap();
app.run("object.move", json!({"dx": 10, "dy": 0})).unwrap();
app.run("select.anchors", json!({"id": id.0, "anchors": [[0, 19]]})).unwrap();
crate::menus::invoke(&mut app, command, json!({}));
settle(&mut app);
assert!(simplify_slider::showing_of(&app, kind));
assert!(app.session.in_interaction());
app.run("file.revert", json!({"confirmed": true})).unwrap();
app.run("select.anchors", json!({"id": id.0, "anchors": [[0, 19]]})).unwrap();
let restored = app.session.active().unwrap().doc.clone();
frame(&mut app, vec![]);
assert!(!simplify_slider::showing_of(&app, kind), "{command}");
assert!(!app.session.in_interaction());
assert_eq!(app.session.active().unwrap().doc, restored);
crate::menus::invoke(&mut app, command, json!({}));
settle(&mut app);
assert!(simplify_slider::showing_of(&app, kind));
assert!(app.session.in_interaction());
}
}