@@ -195,6 +195,7 @@ fn write_impl(
195195 path: Option<&Cow<str>>,
196196 force: bool,
197197) -> anyhow::Result<()> {
198+ let auto_format = cx.editor.config().auto_format;
198199 let jobs = &mut cx.jobs;
199200 let doc = doc_mut!(cx.editor);
200201
@@ -205,17 +206,21 @@ fn write_impl(
205206 if doc.path().is_none() {
206207 bail!("cannot write a buffer without a filename");
207208 }
208− let fmt = doc.auto_format().map(|fmt| {
209− let shared = fmt.shared();
210− let callback = make_format_callback(
211− doc.id(),
212− doc.version(),
213− Modified::SetUnmodified,
214− shared.clone(),
215− );
216− jobs.callback(callback);
217− shared
218− });
209+ let fmt = if auto_format {
210+ doc.auto_format().map(|fmt| {
211+ let shared = fmt.shared();
212+ let callback = make_format_callback(
213+ doc.id(),
214+ doc.version(),
215+ Modified::SetUnmodified,
216+ shared.clone(),
217+ );
218+ jobs.callback(callback);
219+ shared
220+ })
221+ } else {
222+ None
223+ };
219224 let future = doc.format_and_save(fmt, force);
220225 cx.jobs.add(Job::new(future).wait_before_exiting());
221226
@@ -454,6 +459,7 @@ fn write_all_impl(
454459 force: bool,
455460) -> anyhow::Result<()> {
456461 let mut errors = String::new();
462+ let auto_format = cx.editor.config().auto_format;
457463 let jobs = &mut cx.jobs;
458464 // save all documents
459465 for doc in &mut cx.editor.documents.values_mut() {
@@ -466,17 +472,21 @@ fn write_all_impl(
466472 continue;
467473 }
468474
469− let fmt = doc.auto_format().map(|fmt| {
470− let shared = fmt.shared();
471− let callback = make_format_callback(
472− doc.id(),
473− doc.version(),
474− Modified::SetUnmodified,
475− shared.clone(),
476− );
477− jobs.callback(callback);
478− shared
479− });
475+ let fmt = if auto_format {
476+ doc.auto_format().map(|fmt| {
477+ let shared = fmt.shared();
478+ let callback = make_format_callback(
479+ doc.id(),
480+ doc.version(),
481+ Modified::SetUnmodified,
482+ shared.clone(),
483+ );
484+ jobs.callback(callback);
485+ shared
486+ })
487+ } else {
488+ None
489+ };
480490 let future = doc.format_and_save(fmt, force);
481491 jobs.add(Job::new(future).wait_before_exiting());
482492 }