@@ -267,30 +267,32 @@ fn write_impl(
267 path: Option<&Cow<str>>,
267 path: Option<&Cow<str>>,
268 force: bool,
268 force: bool,
269) -> anyhow::Result<()> {
269) -> anyhow::Result<()> {
270− let auto_format = cx.editor.config().auto_format;
270+ let editor_auto_fmt = cx.editor.config().auto_format;
271 let jobs = &mut cx.jobs;
271 let jobs = &mut cx.jobs;
272 let doc = doc_mut!(cx.editor);
272 let doc = doc_mut!(cx.editor);
273+ let path = path.map(AsRef::as_ref);
274 if doc.path().is_none() {
275 if doc.path().is_none() {
275 bail!("cannot write a buffer without a filename");
276 bail!("cannot write a buffer without a filename");
277− let fmt = if auto_format {
278+
279+ let fmt = if editor_auto_fmt {
278 doc.auto_format().map(|fmt| {
280 doc.auto_format().map(|fmt| {
279− let shared = fmt.shared();
280− let callback = make_format_callback(doc.id(), doc.version(), shared.clone());
281+ let callback = make_format_callback(
285+ Some((path.map(Into::into), force)),
281 jobs.add(Job::with_callback(callback).wait_before_exiting());
288 jobs.add(Job::with_callback(callback).wait_before_exiting());
288− doc.format_and_save(fmt, path.map(AsRef::as_ref), force)?;
294+ if fmt.is_none() {
289−
295+ doc.save(path, force)?;
292− doc.detect_language(cx.editor.syn_loader.clone());
293− let _ = cx.editor.refresh_language_server(id);
@@ -345,7 +347,7 @@ fn format(
346 let doc = doc!(cx.editor);
348 let doc = doc!(cx.editor);
347 if let Some(format) = doc.format() {
349 if let Some(format) = doc.format() {
348− let callback = make_format_callback(doc.id(), doc.version(), format);
350+ let callback = make_format_callback(doc.id(), doc.version(), format, None);
349 cx.jobs.callback(callback);
351 cx.jobs.callback(callback);
@@ -592,16 +594,17 @@ fn write_all_impl(
593 let fmt = if auto_format {
595 let fmt = if auto_format {
594 doc.auto_format().map(|fmt| {
596 doc.auto_format().map(|fmt| {
595− let shared = fmt.shared();
597+ let callback =
596− let callback = make_format_callback(doc.id(), doc.version(), shared.clone());
598+ make_format_callback(doc.id(), doc.version(), fmt, Some((None, force)));
597 jobs.callback(callback);
599 jobs.callback(callback);
604− doc.format_and_save::<_, PathBuf>(fmt, None, force)?;
606+ doc.save::<PathBuf>(None, force)?;
607 if quit {
610 if quit {