@@ -195,6 +195,7 @@ fn write_impl(
195 path: Option<&Cow<str>>,
195 path: Option<&Cow<str>>,
196 force: bool,
196 force: bool,
197) -> anyhow::Result<()> {
197) -> anyhow::Result<()> {
198+ let auto_format = cx.editor.config().auto_format;
198 let jobs = &mut cx.jobs;
199 let jobs = &mut cx.jobs;
199 let doc = doc_mut!(cx.editor);
200 let doc = doc_mut!(cx.editor);
@@ -205,17 +206,21 @@ fn write_impl(
205 if doc.path().is_none() {
206 if doc.path().is_none() {
206 bail!("cannot write a buffer without a filename");
207 bail!("cannot write a buffer without a filename");
209+ let fmt = if auto_format {
208− let fmt = doc.auto_format().map(|fmt| {
210+ doc.auto_format().map(|fmt| {
209− let shared = fmt.shared();
211+ let shared = fmt.shared();
210− let callback = make_format_callback(
212+ let callback = make_format_callback(
211− doc.id(),
213+ doc.id(),
212− doc.version(),
214+ doc.version(),
213− Modified::SetUnmodified,
215+ Modified::SetUnmodified,
214− shared.clone(),
216+ shared.clone(),
216− jobs.callback(callback);
218+ jobs.callback(callback);
219 let future = doc.format_and_save(fmt, force);
224 let future = doc.format_and_save(fmt, force);
220 cx.jobs.add(Job::new(future).wait_before_exiting());
225 cx.jobs.add(Job::new(future).wait_before_exiting());
@@ -454,6 +459,7 @@ fn write_all_impl(
454 force: bool,
459 force: bool,
455) -> anyhow::Result<()> {
460) -> anyhow::Result<()> {
456 let mut errors = String::new();
461 let mut errors = String::new();
462+ let auto_format = cx.editor.config().auto_format;
457 let jobs = &mut cx.jobs;
463 let jobs = &mut cx.jobs;
458 // save all documents
464 // save all documents
459 for doc in &mut cx.editor.documents.values_mut() {
465 for doc in &mut cx.editor.documents.values_mut() {
@@ -466,17 +472,21 @@ fn write_all_impl(
466 continue;
472 continue;
475+ let fmt = if auto_format {
469− let fmt = doc.auto_format().map(|fmt| {
476+ doc.auto_format().map(|fmt| {
470− let shared = fmt.shared();
477+ let shared = fmt.shared();
471− let callback = make_format_callback(
478+ let callback = make_format_callback(
472− doc.id(),
479+ doc.id(),
473− doc.version(),
480+ doc.version(),
474− Modified::SetUnmodified,
481+ Modified::SetUnmodified,
475− shared.clone(),
482+ shared.clone(),
477− jobs.callback(callback);
484+ jobs.callback(callback);
480 let future = doc.format_and_save(fmt, force);
490 let future = doc.format_and_save(fmt, force);
481 jobs.add(Job::new(future).wait_before_exiting());
491 jobs.add(Job::new(future).wait_before_exiting());