diff --git a/crates/engine/src/cmd/file.rs b/crates/engine/src/cmd/file.rs index 20b51d80a..f56e3dadf 100644 --- a/crates/engine/src/cmd/file.rs +++ b/crates/engine/src/cmd/file.rs @@ -1279,6 +1279,9 @@ mod new_document_tests { let c = s.preview_new_document(&json!({})).unwrap(); s.execute("frame.create", &json!({"rect": [10, 10, 100, 100]})).unwrap(); assert_eq!(crate::recovery::save(&s, &dir).unwrap(), 0); + // The app's timer saves through the command. + assert_eq!(s.execute("file.recovery.save", &json!({})).unwrap()["saved"], 0); + assert!(crate::recovery::list(&dir).is_empty()); assert_eq!(s.end_new_document_preview(), None); assert_eq!((s.documents().len(), s.doc().unwrap().uid, s.doc().unwrap().doc.title.as_str()), (2, c, "Untitled-2")); s.execute("file.new", &json!({})).unwrap(); diff --git a/crates/engine/src/recovery.rs b/crates/engine/src/recovery.rs index 2a11bceaa..4a96c7571 100644 --- a/crates/engine/src/recovery.rs +++ b/crates/engine/src/recovery.rs @@ -427,7 +427,12 @@ pub(crate) fn save_tracked(s: &mut Session, dir: &Path) -> Result { } prepare_save(s, dir)?; let mut n = 0; + let preview = s.new_document_preview(); for index in 0..s.docs.len() { + // New Document's preview is never written, so it has no checkpoint to discard either. + if s.docs.get(index).is_some_and(|document| preview == Some(document.uid)) { + continue; + } if s.docs.get(index).is_some_and(|document| !document.is_dirty()) { discard_document(s, index, Some(dir)); continue;