From dac9a4cebd39e7865235530fa69e5ae4ab42962b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 10 Jul 2020 23:39:25 +0200 Subject: [PATCH] Don't spawn notify unnecessary --- crates/rust-analyzer/src/reload.rs | 1 + crates/vfs-notify/src/include.rs | 1 - crates/vfs-notify/src/lib.rs | 12 +++++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index ffe234a5bc..a81ecdf208 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -182,6 +182,7 @@ impl GlobalState { } }, }; + let watch = match self.config.files.watcher { FilesWatcher::Client => vec![], FilesWatcher::Notify => project_folders.watch, diff --git a/crates/vfs-notify/src/include.rs b/crates/vfs-notify/src/include.rs index 72f9285369..59da3d77a1 100644 --- a/crates/vfs-notify/src/include.rs +++ b/crates/vfs-notify/src/include.rs @@ -1,5 +1,4 @@ //! See `Include`. - use std::convert::TryFrom; use globset::{Glob, GlobSet, GlobSetBuilder}; diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs index ee50355546..6aaa53f637 100644 --- a/crates/vfs-notify/src/lib.rs +++ b/crates/vfs-notify/src/lib.rs @@ -82,11 +82,13 @@ impl NotifyActor { Event::Message(msg) => match msg { Message::Config(config) => { self.watcher = None; - let (watcher_sender, watcher_receiver) = unbounded(); - let watcher = log_notify_error(Watcher::new_immediate(move |event| { - watcher_sender.send(event).unwrap() - })); - self.watcher = watcher.map(|it| (it, watcher_receiver)); + if !config.watch.is_empty() { + let (watcher_sender, watcher_receiver) = unbounded(); + let watcher = log_notify_error(Watcher::new_immediate(move |event| { + watcher_sender.send(event).unwrap() + })); + self.watcher = watcher.map(|it| (it, watcher_receiver)); + } let n_total = config.load.len(); self.send(loader::Message::Progress { n_total, n_done: 0 });