Merge pull request #2475 from denisg0mes/deleting-a-point-selects-the-next

M8: in vector edit mode, deleting a point selects the next one on its path
This commit is contained in:
BFlat authored and GitHub committed 2026-11-27 14:47:16 +07:00
commit 9342dbc36c
4 files changed
+71 -6

No files matched your search

+43 -4
View File
@@ -642,10 +642,12 @@ fn index(cmd: &str, p: &Value, key: &str) -> Result<usize> {
}
/// Delete the points and segments of `parts` (`heal` keeps paths through deleted points closed).
pub(crate) fn delete_selection(s: &mut Session, parts: Vec<EditPart>, heal: bool) -> Result<()> {
pub(crate) fn delete_selection(s: &mut Session, parts: Vec<EditPart>, heal: bool, then_select_next: bool) -> Result<()> {
let doc = s.doc_mut()?;
let mut next = Vec::new();
for EditPart { id, vertices: verts, segments: segs } in parts {
edit(doc, id, |net| {
let following = edit(doc, id, |net| {
let following = if then_select_next { points_following(net, &verts) } else { Vec::new() };
// Segments first (their indices refer to the network before points go).
let segs: Vec<usize> =
segs.into_iter().filter(|si| net.segments.get(*si).is_some_and(|x| !verts.contains(&x.a) && !verts.contains(&x.b))).collect();
@@ -654,15 +656,52 @@ pub(crate) fn delete_selection(s: &mut Session, parts: Vec<EditPart>, heal: bool
// Point indices may have shifted: find them again by position.
let now: Vec<usize> = pts.iter().filter_map(|p| net.vertices.iter().position(|v| v.point() == *p)).collect();
ops::delete_vertices(net, &now, heal);
following.iter().filter_map(|p| net.vertices.iter().position(|v| v.point() == *p)).collect::<Vec<usize>>()
})?;
next.push((id, following));
}
set_state(s, |ve| {
ve.clear_selection();
ve.anchor = None;
ve.pen_out = None;
for (id, following) in next {
if id == ve.id {
ve.vertices = following;
} else if let Some(o) = ve.others.iter_mut().find(|o| o.id == id) {
o.vertices = following;
}
}
})
}
fn points_following(net: &VectorNetwork, deleted: &[usize]) -> Vec<Point> {
let step = |from: usize, forward: bool| {
net.segments.iter().find_map(|sg| match forward {
true => (sg.a == from).then_some(sg.b),
false => (sg.b == from).then_some(sg.a),
})
};
let mut out: Vec<Point> = Vec::new();
for &v in deleted {
let found = [true, false].into_iter().find_map(|forward| {
let mut at = v;
for _ in 0..net.vertices.len() {
at = step(at, forward)?;
if !deleted.contains(&at) {
return Some(at);
}
}
None
});
if let Some(p) = found.and_then(|i| net.vertices.get(i)).map(|x| x.point())
&& !out.contains(&p)
{
out.push(p);
}
}
out
}
/// The points a command acts on, per layer: `vertices` names points of the active layer; without
/// it, every edited layer's selected points (with `ends`, the ends of selected segments too).
fn point_sets(s: &Session, p: &Value, ends: bool) -> Result<Vec<(NodeId, Vec<usize>)>> {
@@ -1112,7 +1151,7 @@ pub fn specs() -> Vec<CommandSpec> {
}),
spec!("vector.deleteHeal", "Delete and heal selection", "{vertices?} (default the selected points of every edited layer)", true, |s, p| {
let parts = point_sets(s, p, false)?.into_iter().map(|(id, vertices)| EditPart { id, vertices, segments: vec![] }).collect();
delete_selection(s, parts, true)?;
delete_selection(s, parts, true, true)?;
Ok(json!({"ok": true}))
}),
spec!("vector.edit.delete", "Delete points", "{vertices?, segments?} (default the selection in every edited layer)", true, |s, p| {
@@ -1121,7 +1160,7 @@ pub fn specs() -> Vec<CommandSpec> {
(None, None) => ve.parts(),
(v, sg) => vec![EditPart { id: ve.id, vertices: v.unwrap_or_default(), segments: sg.unwrap_or_default() }],
};
delete_selection(s, parts, false)?;
delete_selection(s, parts, false, true)?;
Ok(json!({"ok": true}))
}),
spec!("vector.edit.cornerRadius", "Point corner radius", "{radius, vertices?}", true, |s, p| {
@@ -154,7 +154,7 @@ pub(super) fn cut_selection(s: &mut Session, sel: EditSelection) -> Result<Value
}
let cut = sel.parts.len();
let segments = copy_parts(s, "edit.cut", &sel)?;
vectoredit::delete_selection(s, sel.delete, false)?;
vectoredit::delete_selection(s, sel.delete, false, false)?;
Ok(json!({"cut": cut, "segments": segments}))
}
@@ -700,6 +700,31 @@ fn deleting_points_vs_delete_and_heal() {
assert_eq!((n.vertices.len(), n.segments.len()), (4, 3), "deleting a segment leaves its points");
}
#[test]
fn deleting_a_point_selects_the_next_one_on_its_path() {
let mut s = Session::new();
let id = id_of(&ex(&mut s, "vector.create", json!({"path": "M0 0 L100 0 L200 0 L300 0"}))["id"]).unwrap();
ex(&mut s, "vector.edit.begin", json!({"id": id}));
let selected = |s: &Session| editing(s).unwrap().vertices.iter().map(|v| page_pos(s, id, *v)).collect::<Vec<_>>();
let second = point_at(&s, id, (100.0, 0.0));
ex(&mut s, "vector.edit.select", json!({"vertices": [second]}));
key(&mut s, "Delete", true);
assert_eq!(selected(&s), [Point::new(200.0, 0.0)], "the point after the deleted one");
key(&mut s, "Delete", true);
assert_eq!(selected(&s), [Point::new(300.0, 0.0)], "so Delete again walks along the path");
key(&mut s, "Delete", true);
assert_eq!(selected(&s), [Point::new(0.0, 0.0)], "past the path's end, the point before it");
let mut s = Session::new();
let id = square(&mut s, true);
let tr = point_at(&s, id, (100.0, 0.0));
ex(&mut s, "vector.edit.select", json!({"vertices": [tr]}));
key(&mut s, "Delete", false);
let after = selected(&s);
assert_eq!(after.len(), 1, "one point selected after a plain Delete: {after:?}");
assert!([Point::new(100.0, 100.0), Point::new(0.0, 0.0)].contains(&after[0]), "a neighbour of the deleted corner: {after:?}");
}
#[test]
fn handles_follow_their_mirroring() {
// A smooth middle point at (100, 0) on an open path; one handle is dragged to (+30, 10).
+2 -1
View File
@@ -1,6 +1,6 @@
# UI and interaction parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-24 · **Change:** minor (the hover and selection outline of a curved layer bends smoothly instead of showing straight pieces; text copied while editing, or a whole text layer copied, pastes into a text edit with its formatting and its layer's colour, and Shift+Cmd/Ctrl+V (also Alt+Cmd/Ctrl+V) pastes it in the style at the caret; crop mode: the layer's sides and corners crop its image in an auto layout frame too, up to the image's edges, change a locked ratio (Shift keeps it), the image's own corners scale freely with Shift proportional as a resize does, and crop mode and vector edit mode end each other; after a click on a layer row the arrow keys nudge the selection, or move a layer in an auto layout flow one place, as in Figma; the rows take the arrows once they have the keyboard (F6); Shift+Cmd/Ctrl+V with several layers selected pastes after the last of them as seen: next in an auto layout frame's flow, else below the lowest or right of the rightmost, at the selection's own gap; Tab and Shift+Tab while editing a text layer go on to the next or previous text layer of its frame, in reading order, with all of its text selected; a file opens again on the page and at the view it was left at; the desktop app reopens the files open when it quit, in their tabs' order with the same one in front, and with nothing to reopen starts on the Home screen instead of in a new file; a dropdown, button menu or context menu in the panels that is taller than the window scrolls, so its last rows can be picked; frames, sections, components and instances move, resize and draw on whole pixels whatever Snap to pixel grid says and whatever they snap to, as Figma's help says; the pixel grid shows on a dark canvas and dark fills as well as on white, its lines one screen pixel wide in a light grey at a fifth of its strength, as measured in Figma; Shift+Cmd/Ctrl+' says at the bottom of the window whether snapping to the pixel grid is now on or off; Paste properties links the copied layer's colour, effect, grid and text styles and binds the variables it follows, and a frame's layout grids come along; links another file lacks paste as values; mind maps from the toolbar and the keyboard: Shapes ▸ Mind map places one with a click, Cmd/Ctrl+Enter adds a child and Shift+Cmd/Ctrl+Enter a sibling, Tab goes to the next sibling (#2226); a dragged layer is drawn from a sprite that moves with its outline (#2033); the Scale tool keeps variable-bound lengths scaled: a scaled instance keeps its bindings and draws them at the variable's value times its scale factor, other scaled layers keep the scaled value and drop the binding (#2090); Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers with a padlock and selects them, and shows only with more than one layer under the pointer (#1560); M8: Scale tool hLine truncated
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-24 · **Change:** minor (in vector edit mode, deleting a point selects the next one on its path, so Delete pressed again goes on along it; the hover and selection outline of a curved layer bends smoothly instead of showing straight pieces; text copied while editing, or a whole text layer copied, pastes into a text edit with its formatting and its layer's colour, and Shift+Cmd/Ctrl+V (also Alt+Cmd/Ctrl+V) pastes it in the style at the caret; crop mode: the layer's sides and corners crop its image in an auto layout frame too, up to the image's edges, change a locked ratio (Shift keeps it), the image's own corners scale freely with Shift proportional as a resize does, and crop mode and vector edit mode end each other; after a click on a layer row the arrow keys nudge the selection, or move a layer in an auto layout flow one place, as in Figma; the rows take the arrows once they have the keyboard (F6); Shift+Cmd/Ctrl+V with several layers selected pastes after the last of them as seen: next in an auto layout frame's flow, else below the lowest or right of the rightmost, at the selection's own gap; Tab and Shift+Tab while editing a text layer go on to the next or previous text layer of its frame, in reading order, with all of its text selected; a file opens again on the page and at the view it was left at; the desktop app reopens the files open when it quit, in their tabs' order with the same one in front, and with nothing to reopen starts on the Home screen instead of in a new file; a dropdown, button menu or context menu in the panels that is taller than the window scrolls, so its last rows can be picked; frames, sections, components and instances move, resize and draw on whole pixels whatever Snap to pixel grid says and whatever they snap to, as Figma's help says; the pixel grid shows on a dark canvas and dark fills as well as on white, its lines one screen pixel wide in a light grey at a fifth of its strength, as measured in Figma; Shift+Cmd/Ctrl+' says at the bottom of the window whether snapping to the pixel grid is now on or off; Paste properties links the copied layer's colour, effect, grid and text styles and binds the variables it follows, and a frame's layout grids come along; links another file lacks paste as values; mind maps from the toolbar and the keyboard: Shapes ▸ Mind map places one with a click, Cmd/Ctrl+Enter adds a child and Shift+Cmd/Ctrl+Enter a sibling, Tab goes to the next sibling (#2226); a dragged layer is drawn from a sprite that moves with its outline (#2033); the Scale tool keeps variable-bound lengths scaled: a scaled instance keeps its bindings and draws them at the variable's value times its scale factor, other scaled layers keep the scaled value and drop the binding (#2090); Type settings ▸ Details ▸ Position sets the selected text layers to superscript or subscript, or neither (#2338); Shift with the Pencil, Marker or Highlighter draws one straight segment from where the stroke started, at the nearest 45° step, as the Line tool and the Pen do (#2447); the Design panel's header names a selected component or component set, after its icon, instead of only its type (#2347); dragging near the canvas edge pans the view toward it, as measured in Figma: 40 px/s for each px within about 15 px of the edge, 600 px/s at it, for moving layers, the selection box, drawing and prototype connections (#2015); M8: a Shift-click range in the Layers panel across parents keeps a frame and not its covered children, measured in Figma's web app on 2026-11-12; points align and distribute in vector edit mode as in Figma: the six Align commands, the keys Alt+A/H/D/W/V/S, and Distribute horizontal and vertical spacing act on the selected points, each moving along one axis to their box's edge or centre line, spaced evenly between the outermost for distribute, with the alignment row first in the Design panel (#2109); going back to a page shows it where it was left, not fitted again; Duplicate repeats the last copy's move and its rotation (about the copy's centre, or the selection's centre for several layers), not its size, and forgets the step when the selection changes, measured in Figma's web app on 2026-11-12 (#2293); M8: a double-click on a layer's icon zooms to it instead of renaming, measured in Figma's web app on 2026-11-12; Tidy up keeps the order and sizes and evens the gaps, as measured in Figma's web app on 2026-11-12, rounds the gap half up, tidies overlapping rows and packs a grid along its longer axis, and is greyed out for fewer than three layers, a diagonal and an irregular layout (M8); after Crop is chosen in the image fill's colour picker, a drag on the image crops it instead of moving the layer, and no internal gesture message shows (#2307); Align is disabled for a layer in an auto layout frame's flow, as measured in Figma's web app on 2026-11-12, with a tip saying the frame places it; Select layer lists locked layers wiLine truncated
Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys,
drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status:
@@ -226,6 +226,7 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged
| 2026-11-19 | patch | M5: a click on a row in the Layers panel gave the arrow keys to the rows, so Up and Down moved the selection through the list and Left and Right opened and closed rows. A layer picked there couldn't be nudged, nor moved up or down its vertical auto layout frame. As in Figma, where a locked layer picked in the Layers panel is the one the arrows don't move (row of 2026-11-10), a clicked row now leaves the arrows to the canvas. Walking the rows with the arrows is still there for the keyboard: F6 into the Layers panel puts the keyboard on the selected row. Shift+F10 after a click still opens the menu at the row. Tests: `layers_keys_tests::a_clicked_row_leaves_the_arrows_to_the_canvas`, `down_on_a_clicked_row_moves_it_one_place_in_a_vertical_auto_layout`; the row-walking tests now reach the rows by F6 |
| 2026-11-18 | patch | M1, crop mode (Object ▸ Crop image, #1464): the layer's sides and corners (the Cmd/Ctrl resize crop) crop its image in an auto layout frame too, against the box the layout leaves, instead of squashing the picture; a side can go no further than the image's edge, so no empty strip opens inside the layer (Shift still keeps the ratio and Alt the centre there, and a crop the layout widens slides back along the image); a locked ratio doesn't hold the crop window and Shift keeps its ratio; the image's own corner handles scale it freely and in proportion with Shift, as a resize does (they were the other way round). Crop mode and vector edit mode end each other, and a double-click in crop mode stays in it: with both on, the injected Cmd/Ctrl turned a drag of the layer's side into the Bend tool and showed the selected points' box ("804 × 0"). Tests: `crop_image_tests` (5 new), `transform_behaviour_tests::command_crop_changes_a_locked_ratio_and_stops_at_the_images_edges`, `command_crop_stopped_by_the_image_keeps_the_ratio_with_shift_and_the_centre_with_alt`, `command_crop_slides_back_onto_the_image_when_layout_widens_the_layer`, `command_resize_crops_in_auto_layout_against_the_box_layout_leaves` |
| 2026-11-18 | patch | M4: text copied or cut while editing went to the clipboard as plain characters, so Cmd/Ctrl+V put it in the style at the caret and dropped its font, size, fills and text style; Alt+Cmd/Ctrl+V while editing did nothing. Cmd/Ctrl+V now pastes the characters with the formatting they were copied with while the clipboard still holds the text FigCraft copied (a link to a text style the file doesn't have is dropped, its look kept), and Alt+Cmd/Ctrl+V pastes the clipboard's characters in the style at the caret, as Paste and match style does. Characters coloured by their layer's fill keep that colour, and a whole text layer copied with Cmd/Ctrl+C pastes into a text edit the same way. Shift+Cmd/Ctrl+V while editing does what Alt+Cmd/Ctrl+V does; outside text editing it is still Paste over selection. Shift+Insert pastes as Cmd/Ctrl+V does, and an image fill on the copied characters brings its image into another file, as a pasted layer's does. Text copied in another app pastes as before. Tests: `text_paste_style_tests`, `textedit::tests::rich_text_pastes_its_runs_and_drops_a_link_to_a_style_this_file_lacks`, `textedit::tests::copied_characters_bring_the_image_their_fill_uses_into_another_file` |
| 2026-11-18 | patch | M8: in vector edit mode, deleting a selected point (Delete or Backspace, or Shift+Delete to heal) left nothing selected, so deleting several points along a path meant clicking each one first. The point that followed the deleted one along its path is now selected, the one before it when the deleted point ended the path, so Delete pressed again goes on along it; points and segments cut to the clipboard still leave nothing selected. Test: `vector_behaviour_tests::deleting_a_point_selects_the_next_one_on_its_path` |
| 2026-11-19 | patch | M4, #2338: superscript and subscript were drawn (#1868) but nothing in the interface set them. Type settings ▸ Details now starts with Position: None, Superscript (X²) or Subscript (X₂), for the selected text layers, through `text.setFeatures` (`sups`, `subs`; choosing one clears the other). It shows the layers' current position, none when they differ. Raising a range of characters on its own needs per-run features and is left for a separate change. Test: `typography::variable_tests::details_position_sets_superscript_subscript_or_neither`. |
| 2026-11-19 | patch | M1, #2447: Shift did nothing with the Pencil: a stroke stayed freehand while the Line tool and the Pen keep theirs to 45° steps. With Shift held, the Pencil (and the Marker and Highlighter) now draws one straight segment from where the stroke started to the pointer, at the nearest 45° step; the preview shows it. A Shift-click without a move draws nothing, as before. Tests: `pencil_shift_tests`. |
| 2026-11-19 | patch | M3, #2347: with one component or component set selected, the Design panel's header said only "Component" or "Component set", so the selected one's name was only in the Layers panel. It now shows the name after a component icon (cut short with an ellipsis clear of the quick actions), with the type, and the whole name when cut, on hover. Other layers keep their type. Test: `component_header_tests::the_header_names_the_selected_component_or_set`. |