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`.
pull/9900/head
Luis Useche 8 months ago committed by GitHub
parent 4d2282cbcc
commit 6a22d7d1ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1318,7 +1318,11 @@ fn reload_all(
// Ensure that the view is synced with the document's history. // Ensure that the view is synced with the document's history.
view.sync_changes(doc); view.sync_changes(doc);
doc.reload(view, &cx.editor.diff_providers)?; if let Err(error) = doc.reload(view, &cx.editor.diff_providers) {
cx.editor.set_error(format!("{}", error));
continue;
}
if let Some(path) = doc.path() { if let Some(path) = doc.path() {
cx.editor cx.editor
.language_servers .language_servers

@ -993,11 +993,13 @@ impl Document {
provider_registry: &DiffProviderRegistry, provider_registry: &DiffProviderRegistry,
) -> Result<(), Error> { ) -> Result<(), Error> {
let encoding = self.encoding; let encoding = self.encoding;
let path = self let path = match self.path() {
.path() None => return Ok(()),
.filter(|path| path.exists()) Some(path) => match path.exists() {
.ok_or_else(|| anyhow!("can't find file to reload from {:?}", self.display_name()))? true => path.to_owned(),
.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 // Once we have a valid path we check if its readonly status has changed
self.detect_readonly(); self.detect_readonly();

Loading…
Cancel
Save