Preserve upstream shape addition history alongside the Line Tool label

This commit is contained in:
Dan committed 2026-11-22 18:26:14 +00:00
1 parent d9d3137f13
commit 2f8c8859d8
2 files changed
+3 -2

No files matched your search

@@ -108,7 +108,7 @@ fn a_bad_label_for_a_shape_add_preserves_the_document_and_history() {
let id = s.execute("shape.create", line(None)).unwrap()["layer"].as_u64().unwrap();
let n = steps(&s);
let before = s.active().unwrap().doc.clone();
let mut params = line(Some("Ellipse Tool"));
let mut params = line(Some("Unknown Tool"));
params["addTo"] = json!(id);
assert!(s.execute("shape.create", params).is_err());
assert_eq!(steps(&s), n);
+2 -1
View File
@@ -436,7 +436,7 @@ fn default_name(kind: &str) -> &'static str {
}
/// Creates a shape layer, or adds path components to the shape identified by `addTo`.
/// A tool's optional History name applies to either edit.
/// Line Tool additions keep the tool's History name. Other shape additions use Add Shape.
pub(super) fn shape_create(s: &mut Session, p: &Value) -> Result<Value> {
const CMD: &str = "shape.create";
let add_to = p.get("addTo").and_then(Value::as_u64);
@@ -456,6 +456,7 @@ pub(super) fn shape_create(s: &mut Session, p: &Value) -> Result<Value> {
if let Some(target) = add_to {
let op = p.get("op").and_then(Value::as_str).map_or(Some(PathOp::Combine), op_from).ok_or_else(|| bad(CMD, "unknown `op`"))?;
let id = LayerId(target);
let label = if kind == "line" && label == "Line Tool" { label } else { "Add Shape" };
with_shape(s, id, label, |sh, _| {
for mut sp in path.subpaths {
// A joined subpath (a hole) belongs to the component before it, which takes `op`.