@@ -1160,20 +1160,12 @@ mod cmd {
1160 if doc.path().is_none() {
1160 if doc.path().is_none() {
1161 return Err(anyhow!("cannot write a buffer without a filename"));
1161 return Err(anyhow!("cannot write a buffer without a filename"));
1165− .map(|config| config.auto_format)
1163+ let fmt = doc.auto_format().map(|fmt| {
1166− .unwrap_or_default();
1167− let fmt = if autofmt {
1168− doc.format().map(|fmt| {
1169− let shared = fmt.shared();
1164+ let shared = fmt.shared();
1170− let callback = make_format_callback(doc.id(), doc.version(), true, shared.clone());
1165+ let callback = make_format_callback(doc.id(), doc.version(), true, shared.clone());
1171− jobs.callback(callback);
1166+ jobs.callback(callback);
1177 Ok(tokio::spawn(doc.format_and_save(fmt)))
1169 Ok(tokio::spawn(doc.format_and_save(fmt)))
@@ -1917,6 +1909,9 @@ fn append_to_line(cx: &mut Context) {
1918// Creates an LspCallback that waits for formatting changes to be computed. When they're done,
1910// Creates an LspCallback that waits for formatting changes to be computed. When they're done,
1919// it applies them, but only if the doc hasn't changed.
1911// it applies them, but only if the doc hasn't changed.
1913+// TODO: provide some way to cancel this, probably as part of a more general job cancellation
1920async fn make_format_callback(
1915async fn make_format_callback(
1921 doc_id: DocumentId,
1916 doc_id: DocumentId,
1922 doc_version: i32,
1917 doc_version: i32,