Name untitled designs after their file (#483)
* fix: name an untitled design after its file on save and open Design tabs all read "Untitled" because a design's name only ever came from file.new. Saving a design still under the default name now names it after the file (bracket.solidcraft -> "bracket"), and opening a file whose stored name is the default shows its file name. Names chosen by the user are kept. The rename is part of the save, so it is not an undo step and does not leave the design marked as changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HWLPLy7ug7URSK5WybjRNa * test: expect the file's name after saving an untitled design Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HWLPLy7ug7URSK5WybjRNa --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2880525e6b
commit
219816d282
2 files changed
+119
-6
No files matched your search
@@ -115,10 +115,16 @@ fn lost_attachment_ghost_rebind_preview_cancel_apply_and_undo_preserve_sketch()
|
||||
let repaired = h.app.session.doc.to_json();
|
||||
let path = h.dir.join("rebound-face.solidcraft");
|
||||
h.app.run("file.save", json!({"path":path})).unwrap();
|
||||
// Saving the untitled design names it after its file; everything else is exact.
|
||||
let named = |doc: &str| {
|
||||
let mut doc = solidcraft_engine::doc::Document::from_json(doc).unwrap();
|
||||
doc.name = "rebound-face".into();
|
||||
doc.to_json()
|
||||
};
|
||||
h.app.run("edit.undo", json!({})).unwrap();
|
||||
assert_eq!(h.app.session.doc.to_json(), before);
|
||||
assert_eq!(h.app.session.doc.to_json(), named(&before));
|
||||
h.app.run("doc.open", json!({"path":path})).unwrap();
|
||||
assert_eq!(h.app.session.doc.to_json(), repaired);
|
||||
assert_eq!(h.app.session.doc.to_json(), named(&repaired));
|
||||
assert_eq!(raw_sketch(&h, sketch), raw);
|
||||
assert!(h.app.session.model.result(sketch).unwrap().error.is_none());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user