From 252454021ef619e45aa7ae4fcffa2f9ddacb2fa8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 00:58:26 -0800 Subject: [PATCH] Type: an anchor added to type on a path leaves the type selected whole path.insertAnchor on type on a path, unselected or with selectAnchor, left the new anchor direct-selected under the type's id. The arrow keys and path.moveAnchors then sent that anchor to the path editor, which refused it with "object N is not a path". The type now stays selected whole with no direct-selected anchors, as path.removeAnchor leaves it, so a nudge moves the type. The progress-doc entry now limits the tools to type outside perspective and lists the Pen with Alt with the Anchor Point tool's gestures rather than with adding and deleting anchors. --- crates/engine/src/cmd/path.rs | 16 +++++++++++++++- crates/engine/src/tests/pathtype.rs | 20 ++++++++++++++++++++ docs/mcp.md | 5 +++-- docs/target-app-parity.md | 2 +- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/path.rs b/crates/engine/src/cmd/path.rs index f2c5225f6d..62d6f27e27 100644 --- a/crates/engine/src/cmd/path.rs +++ b/crates/engine/src/cmd/path.rs @@ -149,7 +149,7 @@ pub fn specs() -> Vec { "Add Anchor Point", [], None, - "{id (a path, or type on a path), subpath?, segment, t: 0..1, selectAnchor?: bool (the path becomes the selection with only the new anchor direct-selected, also when it is selected)} add an anchor at t on the segment → {anchor}; the direct-selected anchors and selected segments keep the same points (a selected segment it splits stays selected as its two halves), and a path that isn't selected becomes the selection with the new anchor direct-selected", + "{id (a path, or type on a path), subpath?, segment, t: 0..1, selectAnchor?: bool (the path becomes the selection with only the new anchor direct-selected, also when it is selected)} add an anchor at t on the segment → {anchor}; the direct-selected anchors and selected segments keep the same points (a selected segment it splits stays selected as its two halves), and a path that isn't selected becomes the selection with the new anchor direct-selected; type on a path is left selected whole, with no direct-selected anchors (with selectAnchor, or when it wasn't selected, it becomes the selection)", has_doc, insert_anchor ), @@ -2632,6 +2632,20 @@ fn insert_anchor(s: &mut Session, p: &Value) -> Result { } Ok(sp.insert_anchor(seg, t)) })?; + // Type on a path is selected whole and keeps no direct-selected anchors, as `path.removeAnchor` + // leaves it: the arrow keys and `path.moveAnchors` move anchors of paths only. + if matches!(d.node(id).map(|n| &n.kind), Some(NodeKind::Text(_))) { + if select_anchor || !sel.contains(id) { + sel.clear(); + } + sel.anchors.remove(&id); + sel.segments.remove(&id); + if sel.key_anchor.is_some_and(|(k, _)| k == id) { + sel.key_anchor = None; + } + sel.add(id); + return Ok(idx); + } renumber_after_insert(sel, id, si, idx); // A path that wasn't selected becomes the selection, its new anchor direct-selected, so // the point added shows and can be edited at once (#4237). `selectAnchor` does the same diff --git a/crates/engine/src/tests/pathtype.rs b/crates/engine/src/tests/pathtype.rs index 51141728de..5209950383 100644 --- a/crates/engine/src/tests/pathtype.rs +++ b/crates/engine/src/tests/pathtype.rs @@ -634,3 +634,23 @@ fn add_delete_and_pen_alt_edit_type_on_a_path() { assert!(matches!(text(&s, id).kind, TextKind::OnPath { .. })); assert_eq!(undo_len(&s), n, "Scissors leaves the type whole"); } + +/// #10862: `path.insertAnchor` on type on a path, unselected or with `selectAnchor`, leaves the type +/// selected whole with no direct-selected anchors, so `path.moveAnchors` (the arrow keys) moves +/// the type instead of failing on an anchor that is not a path's. +#[test] +fn an_anchor_added_to_type_on_a_path_leaves_it_selected_whole() { + let mut s = session(); + let id = turned_path_type(&mut s); + for select_anchor in [false, true] { + if !select_anchor { + s.execute("select.set", &json!({"ids": []})).unwrap(); + } + s.execute("path.insertAnchor", &json!({"id": id.0, "segment": 0, "t": 0.5, "selectAnchor": select_anchor})).unwrap(); + let sel = &s.doc().unwrap().selection; + assert!(sel.contains(id) && sel.partial(id).is_none() && !sel.anchors.contains_key(&id), "selectAnchor {select_anchor}"); + let before = type_path(&s, id).subpaths[0].anchors[0].p; + s.execute("path.moveAnchors", &json!({"dx": 10, "dy": 0})).unwrap(); + assert!(close(type_path(&s, id).subpaths[0].anchors[0].p, before + vectorcraft_geom::Vec2::new(10.0, 0.0))); + } +} diff --git a/docs/mcp.md b/docs/mcp.md index e01b4b5a2c..46d1aa1c52 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9442,8 +9442,9 @@ keeps its kind, leave the document as it is and record no undo step. the Anchor Point, Add Anchor Point and Delete Anchor Point tools, the Pen with Alt and the Pen's Auto Add/Delete work on selected type on a path as on a path (#10862); the type lays out again along the edited path, and its brackets keep their fractions of the path. `path.removeAnchor` refuses to leave the type's path with fewer than two anchors, and an -edit that would put it past the canvas is refused; the document does not change. The Scissors tool does not cut type -on a path. +edit that would put it past the canvas is refused; the document does not change. `path.insertAnchor` leaves the type +selected whole, with no direct-selected anchors, so the arrow keys and `path.moveAnchors` move the whole type. The +Scissors tool does not cut type on a path. On a path with Live Corners that store a radius (rounded, or straightened by an earlier move), `path.moveAnchor` and `path.moveAnchors` (and the arrow keys) move the uncut corner each moved anchor belongs to by the drag delta and cut the corners again at their radii. The corners stay live; a live diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index be8a5089f4..57c5ec51d1 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -832,7 +832,7 @@ since 2026-10-01. - **Link cursor for loaded text:** with text loaded from a port, the Selection tool's pointer adds a link badge over a closed path, area type or type on a path that a click threads the text into, and keeps the loaded text elsewhere; a click on a frame already in a thread or a path inside a compound path makes a new frame instead of a `text.thread.add` error (`select::tests::loaded_text_shows_the_link_cursor_where_a_click_threads_it_into_the_object`, `cursors::tests::loaded_text_link_cursor_is_the_loaded_text_with_a_link_badge`); score unchanged. - **Copy and Cut of anchors picked with a lent Direct Selection (#6123):** with the Pen or the Curvature tool, Cmd/Ctrl held lends Direct Selection for the gesture; the anchors and segments it picks are what Edit › Copy and Cut take once the key is let go, as with Direct Selection chosen, while the last anchor the Pen leaves selected as it draws still makes Copy take the whole path (#2122). A Cmd gesture that leaves the selection as it was (a Shift marquee over nothing) picks nothing. Regression test: `tests::draw2::pen_cmd_selected_anchors_are_what_copy_and_cut_take`. - **Mirrored handles in a Direct Selection drag (#7842):** Cmd/Ctrl added after a handle drag begins puts the anchor's other handle opposite the dragged one at the same length, on paths, type on a path and blend spines, and the anchor keeps its kind; Shift constrains the dragged handle first, and Alt keeps the handles independent. At an open end, where no segment leaves the anchor on the other side, the handle moves as it does without Cmd/Ctrl. When Cmd/Ctrl lends Direct Selection for the gesture while another tool, such as the Pen, is chosen, that press does not mirror; letting it go and pressing it again during the drag does. This is VectorCraft's own behavior. Regression tests: `crates/engine/tests/it/direct_handle_mirror.rs`. -- **Anchor tools on type on a path (#10862):** the Anchor Point tool pulls handles out of, converts, moves and bends the path of selected type on a path, and the Add and Delete Anchor Point tools, the Pen with Alt and the Pen's Auto Add/Delete add and delete its anchors, as on a path; the type lays out again along the edited path, and its path keeps two anchors at least. Regression tests: `anchor_point_tool_pulls_handles_out_of_type_on_a_path`, `anchor_point_tool_reshapes_type_on_a_path` and `add_delete_and_pen_alt_edit_type_on_a_path` in `crates/engine/src/tests/pathtype.rs`, `anchor_tools_edit_selected_type_on_a_path` in `crates/tools/src/draw2/anchor/tests.rs`. +- **Anchor tools on type on a path (#10862):** on selected type on a path outside perspective, the Anchor Point tool and the Pen with Alt (which uses the Anchor Point tool's gestures) pull handles out of, convert, move and bend the type's path, and the Add and Delete Anchor Point tools and the Pen's Auto Add/Delete add and delete its anchors, as on a path; the type lays out again along the edited path, and its path keeps two anchors at least. Type on a path in perspective is not edited by these tools. An anchor added to the type leaves the type selected whole. Regression tests: `anchor_point_tool_pulls_handles_out_of_type_on_a_path`, `anchor_point_tool_reshapes_type_on_a_path`, `add_delete_and_pen_alt_edit_type_on_a_path` and `an_anchor_added_to_type_on_a_path_leaves_it_selected_whole` in `crates/engine/src/tests/pathtype.rs`, `anchor_tools_edit_selected_type_on_a_path` in `crates/tools/src/draw2/anchor/tests.rs`. - **Cut of picked anchors (#6361):** Edit › Cut removes direct-selected anchors from their path and from a compound path's member, with the segments attached to them, as Clear does. Picked segments still lose only those segments. When a path also has a picked segment, Cut removes and copies only its picked segments and ignores its picked anchors, on every contour, as Clear does; an anchor left without a surviving segment is removed with them. Regression tests: `cut_*_anchors_*` and `cut_of_an_anchor_with_a_segment_on_another_contour_leaves_the_source_as_clear_does` in `crates/engine/tests/it/copy_direct_selection.rs`. - **Escape in Selection tool drags:** Escape during a Selection tool move or Alt-drag copy, a bounding-box scale or rotation, a marquee, or a corner widget, pie widget or bracket drag cancels it: the art returns to its state at the press, no copy is left, no undo step is added, the release does nothing, and the tool stays chosen. This is VectorCraft's own behavior. Regression tests: `escape_cancels_*` in `select/tests.rs` and `pie.rs`, and `escape_cancels_a_selection_tool_move_copy_scale_or_rotation` in `tests/selectescape.rs`. - **Commands run during a tool drag:** by VectorCraft's own rule, a command that changes the document while a tool drag is in progress (from a panel, a menu or `run_command`) records its own undo step before the drag's. The drag goes on with the art the command left, Escape cancels only the drag, and Undo takes back the drag first and the command next, with Real-time Drawing on or off. A selection the command makes does not change which objects the drag moves. Commands that keep the drag as a step first (Undo, Redo, `command.batch` and others), a Quick Pen press, and a copy made with `object.transform` during an Alt-drag work as before. Regression tests: `crates/engine/src/tests/interaction_commands.rs` and `tests::drag_commands` in `crates/ui-egui`.