@@ -2279,7 +2279,7 @@ pub mod cmd {
2279 force: bool,
2279 force: bool,
2280 ) -> anyhow::Result<()> {
2280 ) -> anyhow::Result<()> {
2281 let mut errors = String::new();
2281 let mut errors = String::new();
2282−
2282+ let jobs = &mut cx.jobs;
2283 // save all documents
2283 // save all documents
2284 for doc in &mut cx.editor.documents.values_mut() {
2284 for doc in &mut cx.editor.documents.values_mut() {
2285 if doc.path().is_none() {
2285 if doc.path().is_none() {
@@ -2287,9 +2287,23 @@ pub mod cmd {
2287 continue;
2287 continue;
2290− // TODO: handle error.
2290+ if !doc.is_modified() {
2291− let handle = doc.save();
2291+ continue;
2294+ let fmt = doc.auto_format().map(|fmt| {
2295+ let shared = fmt.shared();
2296+ let callback = make_format_callback(
2299+ Modified::SetUnmodified,
2302+ jobs.callback(callback);
2305+ let future = doc.format_and_save(fmt);
2292− cx.jobs.add(Job::new(handle).wait_before_exiting());
2306+ jobs.add(Job::new(future).wait_before_exiting());
2295 if quit {
2309 if quit {