|
|
@ -543,7 +543,8 @@ impl Document {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(fmt) = formatting {
|
|
|
|
if let Some(fmt) = formatting {
|
|
|
|
let transaction = fmt.await?;
|
|
|
|
match fmt.await {
|
|
|
|
|
|
|
|
Ok(transaction) => {
|
|
|
|
let success = transaction.changes().apply(&mut text);
|
|
|
|
let success = transaction.changes().apply(&mut text);
|
|
|
|
if !success {
|
|
|
|
if !success {
|
|
|
|
// This shouldn't happen, because the transaction changes were generated
|
|
|
|
// This shouldn't happen, because the transaction changes were generated
|
|
|
@ -551,6 +552,12 @@ impl Document {
|
|
|
|
log::error!("failed to apply format changes before saving");
|
|
|
|
log::error!("failed to apply format changes before saving");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Err(err) => {
|
|
|
|
|
|
|
|
// formatting failed: report error, and save file without modifications
|
|
|
|
|
|
|
|
log::error!("{}", err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let mut file = File::create(path).await?;
|
|
|
|
let mut file = File::create(path).await?;
|
|
|
|
to_writer(&mut file, encoding, &text).await?;
|
|
|
|
to_writer(&mut file, encoding, &text).await?;
|
|
|
|