mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-05 18:19:57 +00:00
Edit › Clear with points selected deletes the points, not their paths
The Delete key already ran path.deletePoints under Direct Selection, but Edit › Clear (the menu item, a native accelerator, or the control channel) called edit.clear, which removed every path whose points were selected. With points selected and no ids given, edit.clear now deletes those points, as InDesign's Clear does. Found by CodeRabbit on #1657. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
db1e7b182c
commit
c6821516e5
2 files changed
+9
-1
No files matched your search
@@ -577,6 +577,10 @@ mod tests {
|
||||
assert_eq!(r["removed"], json!([l]));
|
||||
assert!(s.doc().unwrap().doc.item(ItemId(l)).is_none());
|
||||
assert!(s.execute("path.deletePoints", &json!({"points": []})).is_err());
|
||||
// Edit › Clear with points selected deletes the points, not their paths.
|
||||
s.execute("selection.set", &json!({"anchors": [[a, 0, 0]]})).unwrap();
|
||||
s.execute("edit.clear", &json!({})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().doc.item(ItemId(a)).unwrap().path.subpaths[0].anchors.len(), 3, "one point gone, the frame stays");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -289,7 +289,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Clear",
|
||||
["Edit"],
|
||||
Some("Delete"),
|
||||
"{ids?} — delete selected items (or the selected text or ruler guides)",
|
||||
"{ids?} — delete selected items (or the selected text, points or ruler guides)",
|
||||
has_doc,
|
||||
|s, p| {
|
||||
if s.doc()?.selection.text.is_some() && p.get("ids").is_none() {
|
||||
@@ -298,6 +298,10 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
if p.get("ids").is_none() && s.doc()?.selection.items.is_empty() && !s.doc()?.selection.guides.is_empty() {
|
||||
return s.execute("guide.delete", &json!({}));
|
||||
}
|
||||
// Points selected with Direct Selection: they go, not their paths (as InDesign).
|
||||
if p.get("ids").is_none() && !s.doc()?.selection.anchors.is_empty() {
|
||||
return s.execute("path.deletePoints", &json!({}));
|
||||
}
|
||||
let ids = super::targets(s, p)?;
|
||||
// With a placed graphic itself selected (Direct Selection), only the graphic goes: its
|
||||
// frame stays, empty and selected (as in InDesign). Other items are deleted.
|
||||
|
||||
Reference in new issue
Block a user