Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Avoid blocking forever on startup if config files do not exist

Julia51c82da84012
diff --git a/crates/settings/src/settings_file.rs b/crates/settings/src/settings_file.rs
index 4c98dca51a4..3505330eda6 100644
--- a/crates/settings/src/settings_file.rs
+++ b/crates/settings/src/settings_file.rs
@@ -66,15 +66,22 @@ pub fn watch_config_file(
.spawn(async move {
let events = fs.watch(&path, Duration::from_millis(100)).await;
futures::pin_mut!(events);
+
+ let contents = fs.load(&path).await.unwrap_or_default();
+ if tx.unbounded_send(contents).is_err() {
+ return;
+ }
+
loop {
+ if events.next().await.is_none() {
+ break;
+ }
+
if let Ok(contents) = fs.load(&path).await {
if !tx.unbounded_send(contents).is_ok() {
break;
}
}
- if events.next().await.is_none() {
- break;
- }
}
})
.detach();