aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/document.rs
diff options
context:
space:
mode:
authorA-Walrus2022-09-07 07:22:48 +0000
committerGitHub2022-09-07 07:22:48 +0000
commitfe37a66046b16eaf7829606f7b90c18bd73fae3e (patch)
treeed5f7b4bffcaa03ffb55b1d4a6d4b0a8fdff5833 /helix-view/src/document.rs
parent301f5d7cf704c2f2e4fc53e258125e39d1845176 (diff)
Handle formatter errors, and save anyway (#3684)
If formatting fails, report error to log and save without formatting.
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r--helix-view/src/document.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 3f8dc4e6..a0d50440 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -543,12 +543,19 @@ impl Document {
}
if let Some(fmt) = formatting {
- let transaction = fmt.await?;
- let success = transaction.changes().apply(&mut text);
- if !success {
- // This shouldn't happen, because the transaction changes were generated
- // from the same text we're saving.
- log::error!("failed to apply format changes before saving");
+ match fmt.await {
+ Ok(transaction) => {
+ let success = transaction.changes().apply(&mut text);
+ if !success {
+ // This shouldn't happen, because the transaction changes were generated
+ // 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);
+ }
}
}