Background save edited meanwhile: undoing back to the saved state is unmodified (#1721)
This commit is contained in:
parent
b8744f6d33
commit
8a7e36ede8
|
|
@ -609,8 +609,11 @@ impl SaveJob {
|
||||||
if Arc::ptr_eq(&st.doc, &self.source) {
|
if Arc::ptr_eq(&st.doc, &self.source) {
|
||||||
st.doc = self.snapshot.clone();
|
st.doc = self.snapshot.clone();
|
||||||
} else {
|
} else {
|
||||||
// Edited while the save ran: the dates still go on, the edits stay unsaved.
|
// Edited while the save ran: the dates still go on, the edits stay unsaved. The
|
||||||
|
// undo history holds the document as it was before the dates, so that is the
|
||||||
|
// saved state: undoing back to it leaves the document unmodified.
|
||||||
stamp_save_dates(st, at);
|
stamp_save_dates(st, at);
|
||||||
|
return st.mark_saved_as(&self.source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
st.mark_saved_as(&self.snapshot);
|
st.mark_saved_as(&self.snapshot);
|
||||||
|
|
|
||||||
|
|
@ -523,4 +523,7 @@ fn a_failed_save_does_not_stamp_the_documents_dates() {
|
||||||
assert_eq!(st.doc.metadata.modified, Some(777));
|
assert_eq!(st.doc.metadata.modified, Some(777));
|
||||||
assert_eq!(st.path.as_deref(), Some("/x/z.vectorcraft"));
|
assert_eq!(st.path.as_deref(), Some("/x/z.vectorcraft"));
|
||||||
assert!(st.is_dirty());
|
assert!(st.is_dirty());
|
||||||
|
// Undoing the edit is back at what the file holds.
|
||||||
|
s.execute("edit.undo", &json!({})).unwrap();
|
||||||
|
assert!(!s.doc().unwrap().is_dirty());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,9 @@ fn a_50k_path_save_returns_at_once_and_the_file_appears_later() {
|
||||||
assert!(written(&files).is_empty(), "nothing written yet");
|
assert!(written(&files).is_empty(), "nothing written yet");
|
||||||
assert_eq!(app.background.jobs.len(), 1);
|
assert_eq!(app.background.jobs.len(), 1);
|
||||||
assert!(app.ui.status.starts_with("Saving big.vectorcraft"));
|
assert!(app.ui.status.starts_with("Saving big.vectorcraft"));
|
||||||
// The document is saved once the file is written.
|
// The file is the document's once it is written (and its dates are stamped then, #1721: until
|
||||||
assert!(app.session.doc().unwrap().is_dirty() && app.session.doc().unwrap().path.is_none());
|
// then this document, never edited, is as it was).
|
||||||
|
assert!(!app.session.doc().unwrap().is_dirty() && app.session.doc().unwrap().path.is_none());
|
||||||
gate.open();
|
gate.open();
|
||||||
background::wait_all(&mut app);
|
background::wait_all(&mut app);
|
||||||
assert_eq!(written(&files), ["/docs/big.vectorcraft"]);
|
assert_eq!(written(&files), ["/docs/big.vectorcraft"]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue