From ddc5a3e5679bab2ae574fcfc6b7afcbd31b702bc Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 24 Jun 2020 16:56:27 +0200 Subject: Fix infinite cargo check bug --- crates/rust-analyzer/src/main_loop.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 390c66dfc..755fd23b3 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -306,7 +306,7 @@ fn loop_turn( } } vfs::loader::Message::Progress { n_entries_total, n_entries_done } => { - if n_entries_done == n_entries_done { + if n_entries_done == n_entries_total { loop_state.status = Status::Ready; became_ready = true; } -- cgit v1.2.3 From 6937bcb67d825938d862cd1792af02e00e1d1a06 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 24 Jun 2020 16:58:49 +0200 Subject: Less error-prone naming --- crates/rust-analyzer/src/cli/load_cargo.rs | 4 ++-- crates/rust-analyzer/src/main_loop.rs | 12 +++--------- crates/vfs-notify/src/lib.rs | 9 +++------ crates/vfs/src/loader.rs | 8 ++++---- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index 9c510bb62..92e9b60fc 100644 --- a/crates/rust-analyzer/src/cli/load_cargo.rs +++ b/crates/rust-analyzer/src/cli/load_cargo.rs @@ -67,8 +67,8 @@ pub(crate) fn load( // wait until Vfs has loaded all roots for task in receiver { match task { - vfs::loader::Message::Progress { n_entries_done, n_entries_total } => { - if n_entries_done == n_entries_total { + vfs::loader::Message::Progress { n_done, n_total } => { + if n_done == n_total { break; } } diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 755fd23b3..b55d45cd3 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -305,18 +305,12 @@ fn loop_turn( } } } - vfs::loader::Message::Progress { n_entries_total, n_entries_done } => { - if n_entries_done == n_entries_total { + vfs::loader::Message::Progress { n_total, n_done } => { + if n_done == n_total { loop_state.status = Status::Ready; became_ready = true; } - report_progress( - loop_state, - &connection.sender, - n_entries_done, - n_entries_total, - "roots scanned", - ) + report_progress(loop_state, &connection.sender, n_done, n_total, "roots scanned") } }, Event::CheckWatcher(task) => on_check_task(task, global_state, task_sender)?, diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs index 5b4978285..b3d7c414c 100644 --- a/crates/vfs-notify/src/lib.rs +++ b/crates/vfs-notify/src/lib.rs @@ -89,8 +89,8 @@ impl LoaderActor { match event { Event::Message(msg) => match msg { Message::Config(config) => { - let n_entries_total = config.load.len(); - self.send(loader::Message::Progress { n_entries_total, n_entries_done: 0 }); + let n_total = config.load.len(); + self.send(loader::Message::Progress { n_total, n_done: 0 }); self.unwatch_all(); self.config.clear(); @@ -99,10 +99,7 @@ impl LoaderActor { let watch = config.watch.contains(&i); let files = self.load_entry(entry, watch); self.send(loader::Message::Loaded { files }); - self.send(loader::Message::Progress { - n_entries_total, - n_entries_done: i + 1, - }); + self.send(loader::Message::Progress { n_total, n_done: i + 1 }); } self.config.sort_by(|x, y| x.0.cmp(&y.0)); } diff --git a/crates/vfs/src/loader.rs b/crates/vfs/src/loader.rs index 052803dd9..6de2e5b3f 100644 --- a/crates/vfs/src/loader.rs +++ b/crates/vfs/src/loader.rs @@ -16,7 +16,7 @@ pub struct Config { } pub enum Message { - Progress { n_entries_total: usize, n_entries_done: usize }, + Progress { n_total: usize, n_done: usize }, Loaded { files: Vec<(AbsPathBuf, Option>)> }, } @@ -56,10 +56,10 @@ impl fmt::Debug for Message { Message::Loaded { files } => { f.debug_struct("Loaded").field("n_files", &files.len()).finish() } - Message::Progress { n_entries_total, n_entries_done } => f + Message::Progress { n_total, n_done } => f .debug_struct("Progress") - .field("n_entries_total", n_entries_total) - .field("n_entries_done", n_entries_done) + .field("n_total", n_total) + .field("n_done", n_done) .finish(), } } -- cgit v1.2.3 From 089ea36b2ecf5d7267f8a671c077357aad50b8e2 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 24 Jun 2020 17:11:07 +0200 Subject: Don't watch dirs if not asked to --- crates/vfs-notify/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs index 5b4978285..2e60fe23b 100644 --- a/crates/vfs-notify/src/lib.rs +++ b/crates/vfs-notify/src/lib.rs @@ -199,7 +199,7 @@ impl LoaderActor { let is_dir = entry.file_type().is_dir(); let is_file = entry.file_type().is_file(); let abs_path = AbsPathBuf::try_from(entry.into_path()).unwrap(); - if is_dir { + if is_dir && watch { self.watch(abs_path.clone()); } let rel_path = abs_path.strip_prefix(&path)?; -- cgit v1.2.3