mirror of https://github.com/helix-editor/helix
Handle formatter errors, and save anyway (#3684)
If formatting fails, report error to log and save without formatting.pull/3015/head
parent
301f5d7cf7
commit
fe37a66046
|
@ -543,12 +543,19 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(fmt) = formatting {
|
if let Some(fmt) = formatting {
|
||||||
let transaction = fmt.await?;
|
match fmt.await {
|
||||||
let success = transaction.changes().apply(&mut text);
|
Ok(transaction) => {
|
||||||
if !success {
|
let success = transaction.changes().apply(&mut text);
|
||||||
// This shouldn't happen, because the transaction changes were generated
|
if !success {
|
||||||
// from the same text we're saving.
|
// This shouldn't happen, because the transaction changes were generated
|
||||||
log::error!("failed to apply format changes before saving");
|
// from the same text we're saving.
|
||||||
|
log::error!("failed to apply format changes before saving");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
// formatting failed: report error, and save file without modifications
|
||||||
|
log::error!("{}", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue