aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/document.rs
diff options
context:
space:
mode:
authorLuis Useche2024-03-19 11:16:30 +0000
committerGitHub2024-03-19 11:16:30 +0000
commit6a22d7d1cad8fde27d8ba02629c3d33ab535f7b5 (patch)
treefa1748be525a0851eadef48dca8a04333a250d85 /helix-view/src/document.rs
parent4d2282cbccff4dd0aaa901a3ea4fb28a2b8120aa (diff)
Do not stop reloading docs on error (#9870)
In the `reload-all` command, we should not stop reloading the documents if one error is found. Instead, we should report the error and continue trying to reload the current open documents. This is useful in cases where a backing file does not exist temporarily (e.g. when editing a git patch in the outstanding chain that doesn't have a file just yet). This change also remove the error messages in the cases where the backing is `None`, like in new docs or `tutor`.
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r--helix-view/src/document.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 5f3595ee..f813c742 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -993,11 +993,13 @@ impl Document {
provider_registry: &DiffProviderRegistry,
) -> Result<(), Error> {
let encoding = self.encoding;
- let path = self
- .path()
- .filter(|path| path.exists())
- .ok_or_else(|| anyhow!("can't find file to reload from {:?}", self.display_name()))?
- .to_owned();
+ let path = match self.path() {
+ None => return Ok(()),
+ Some(path) => match path.exists() {
+ true => path.to_owned(),
+ false => bail!("can't find file to reload from {:?}", self.display_name()),
+ },
+ };
// Once we have a valid path we check if its readonly status has changed
self.detect_readonly();