From d40a58b6cae71c0c238e10f10e2fdc084cb0b57f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 15 Nov 2026 20:00:55 -0800 Subject: [PATCH] Polygonal Lasso: a dropped press after Backspace keeps earlier vertices Backspace during a press removed the vertex the press had set but left the press marked as owning a vertex, so a dropped press then removed the vertex before it. Removing a vertex now clears that mark. --- crates/tools/src/addons/polygonal_lasso.rs | 3 ++- crates/tools/src/addons/polygonal_lasso/tests.rs | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/tools/src/addons/polygonal_lasso.rs b/crates/tools/src/addons/polygonal_lasso.rs index ad7db575e6..1838293b66 100644 --- a/crates/tools/src/addons/polygonal_lasso.rs +++ b/crates/tools/src/addons/polygonal_lasso.rs @@ -46,10 +46,11 @@ impl PolygonalLassoTool { } /// Removes the last vertex and hides the segment that followed the pointer until the pointer - /// moves again. + /// moves again. A press in progress no longer owns a vertex, so dropping it removes nothing more. fn take_back_vertex(&mut self) { self.vertices.pop(); self.hover = None; + self.pressed_vertex = false; } fn clear(&mut self) { diff --git a/crates/tools/src/addons/polygonal_lasso/tests.rs b/crates/tools/src/addons/polygonal_lasso/tests.rs index 6da31960be..cf2b9e6f70 100644 --- a/crates/tools/src/addons/polygonal_lasso/tests.rs +++ b/crates/tools/src/addons/polygonal_lasso/tests.rs @@ -221,6 +221,19 @@ fn a_dropped_press_takes_back_only_its_vertex() { assert_eq!(tool.hover, None); } +#[test] +fn a_dropped_press_after_backspace_keeps_the_earlier_vertices() { + let (d, _) = doc_with_rect(); + let (s, p) = (Selection::default(), paint()); + let cx = cx(&d, &s, &p); + let mut tool = PolygonalLassoTool::default(); + clicks(&mut tool, &cx, &CORNER[..2], Mods::default()); + tool.pointer(&cx, &PointerEvent::new(PointerKind::Down, 80.0, 140.0)); + assert!(tool.key(&cx, ToolKey::Backspace, Mods::default()).is_empty()); + assert!(tool.drop_press(&cx).is_empty()); + assert_eq!(tool.vertices, vec![Point::new(80.0, 80.0), Point::new(140.0, 80.0)]); +} + #[test] fn the_tool_shows_the_lasso_cursor() { let (d, _) = doc_with_rect();