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.
This commit is contained in:
dotCooCoo
2026-11-15 20:00:55 -08:00
parent 763be536f5
commit d40a58b6ca
2 changed files with 15 additions and 1 deletions
+2 -1
View File
@@ -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) {
@@ -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();