From fd8336c8cbc00b00493f10460fadfa0002f31f33 Mon Sep 17 00:00:00 2001 From: CharlesChen0823 Date: Wed, 15 May 2024 02:00:26 +0800 Subject: [PATCH] linux: Handle modification events from file watcher (#11778) Fixed #11595 Release Notes: - N/A --- crates/fs/src/fs.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rs index 6b4af4bd97..33357539ac 100644 --- a/crates/fs/src/fs.rs +++ b/crates/fs/src/fs.rs @@ -415,7 +415,7 @@ impl Fs for RealFs { path: &Path, _latency: Duration, ) -> Pin>>> { - use notify::{event::EventKind, Watcher}; + use notify::{event::EventKind, event::ModifyKind, Watcher}; // todo(linux): This spawns two threads, while the macOS impl // only spawns one. Can we use a OnceLock or some such to make // this better @@ -443,6 +443,17 @@ impl Fs for RealFs { if let Some(event) = event.ok() { if event.paths.into_iter().any(|path| *path == watched_path) { match event.kind { + EventKind::Modify(ev) => { + if matches!(ev, ModifyKind::Name(_)) { + file_watcher + .watch( + watched_path.as_path(), + notify::RecursiveMode::Recursive, + ) + .log_err(); + let _ = tx.try_send(vec![watched_path.clone()]).ok(); + } + } EventKind::Create(_) => { file_watcher .watch(watched_path.as_path(), notify::RecursiveMode::Recursive)