Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Pen resume: undo that drops a resumed draft clears its ⌘ selection

Hector Villarrealc642bfbe6486
diff --git a/crates/ui-egui/src/pen_variants_tests.rs b/crates/ui-egui/src/pen_variants_tests.rs
index 257e4f591..f82d049ea 100644
--- a/crates/ui-egui/src/pen_variants_tests.rs
+++ b/crates/ui-egui/src/pen_variants_tests.rs
@@ -253,7 +253,12 @@ fn undo_in_a_resumed_draft_stops_at_the_paths_own_anchors() {
click(&mut app, 80.0, 80.0);
assert!(crate::vector_ui::pen_undo_last_point(&mut app), "takes back the added anchor");
assert_eq!(app.ui.pen.as_ref().map(|p| p.knots.len()), Some(2));
+ // A ⌘/Ctrl selection on the draft's anchors.
+ app.ui.direct_selection.target = Some(crate::direct_select::PathRef::Pen);
+ app.ui.direct_selection.anchors = vec![[0, 1]];
assert!(crate::vector_ui::pen_undo_last_point(&mut app), "drops the draft");
assert!(app.ui.pen.is_none());
+ assert_eq!(app.ui.direct_selection.target, None, "the selection on the dropped draft goes with it");
+ assert!(app.ui.direct_selection.anchors.is_empty());
assert_eq!(work_path(&app), before, "the path is as it was");
}
diff --git a/crates/ui-egui/src/vector_ui.rs b/crates/ui-egui/src/vector_ui.rs
index 0161703c8..8a18ad8f4 100644
--- a/crates/ui-egui/src/vector_ui.rs
+++ b/crates/ui-egui/src/vector_ui.rs
@@ -311,6 +311,10 @@ pub fn pen_undo_last_point(app: &mut PhotocraftApp) -> bool {
// A resumed path's own anchors are not the draft's to take back: undoing past the ones added
// since it resumed drops the draft and leaves the path as it was (#6593).
if pen.resumes.as_ref().is_some_and(|r| pen.knots.len() <= r.was.knots.len()) {
+ // A ⌘/Ctrl selection on the draft goes with it.
+ if app.ui.direct_selection.target == Some(crate::direct_select::PathRef::Pen) {
+ app.ui.direct_selection = Default::default();
+ }
app.ui.pen = None;
return true;
}