mirror of
https://github.com/storytold/designcraft.git
synced 2026-10-29 12:46:53 -06:00
Integration (new-doc-preview x #616): the recovery timer's file.recovery.save skips the New Document preview
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -427,7 +427,12 @@ pub(crate) fn save_tracked(s: &mut Session, dir: &Path) -> Result<usize> {
|
||||
}
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user