@@ -543,12 +543,19 @@ impl Document {
543543 }
544544
545545 if let Some(fmt) = formatting {
546− let transaction = fmt.await?;
547− let success = transaction.changes().apply(&mut text);
548− if !success {
549− // This shouldn't happen, because the transaction changes were generated
550− // from the same text we're saving.
551− log::error!("failed to apply format changes before saving");
546+ match fmt.await {
547+ Ok(transaction) => {
548+ let success = transaction.changes().apply(&mut text);
549+ if !success {
550+ // This shouldn't happen, because the transaction changes were generated
551+ // from the same text we're saving.
552+ log::error!("failed to apply format changes before saving");
553+ }
554+ }
555+ Err(err) => {
556+ // formatting failed: report error, and save file without modifications
557+ log::error!("{}", err);
558+ }
552559 }
553560 }
554561