about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/load-cargo/src/lib.rs2
-rw-r--r--crates/rust-analyzer/src/main_loop.rs17
-rw-r--r--crates/vfs-notify/src/lib.rs28
-rw-r--r--crates/vfs/src/loader.rs14
4 files changed, 54 insertions, 7 deletions
diff --git a/crates/load-cargo/src/lib.rs b/crates/load-cargo/src/lib.rs
index e6ddfd580c3..8f02f20ad1b 100644
--- a/crates/load-cargo/src/lib.rs
+++ b/crates/load-cargo/src/lib.rs
@@ -317,7 +317,7 @@ fn load_crate_graph(
     // wait until Vfs has loaded all roots
     for task in receiver {
         match task {
-            vfs::loader::Message::Progress { n_done, n_total, config_version: _ } => {
+            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 ca7893faf5d..714476c482c 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -586,7 +586,7 @@ impl GlobalState {
                     }
                 }
             }
-            vfs::loader::Message::Progress { n_total, n_done, config_version } => {
+            vfs::loader::Message::Progress { n_total, n_done, file, config_version } => {
                 always!(config_version <= self.vfs_config_version);
 
                 self.vfs_progress_config_version = config_version;
@@ -601,10 +601,23 @@ impl GlobalState {
                     assert_eq!(n_done, n_total);
                     Progress::End
                 };
+
+                let mut message = format!("{n_done}/{n_total}");
+                if let Some(file) = file {
+                    message += &format!(
+                        ": {}",
+                        match file.strip_prefix(&self.config.root_path()) {
+                            Some(relative_path) => relative_path.as_ref(),
+                            None => file.as_ref(),
+                        }
+                        .display()
+                    );
+                }
+
                 self.report_progress(
                     "Roots Scanned",
                     state,
-                    Some(format!("{n_done}/{n_total}")),
+                    Some(message),
                     Some(Progress::fraction(n_done, n_total)),
                     None,
                 );
diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs
index 19b34ffe6b9..a6e4da5615b 100644
--- a/crates/vfs-notify/src/lib.rs
+++ b/crates/vfs-notify/src/lib.rs
@@ -103,21 +103,39 @@ impl NotifyActor {
                         let config_version = config.version;
 
                         let n_total = config.load.len();
-                        self.send(loader::Message::Progress { n_total, n_done: 0, config_version });
+                        self.send(loader::Message::Progress {
+                            n_total,
+                            n_done: 0,
+                            config_version,
+                            file: None,
+                        });
 
                         self.watched_entries.clear();
 
                         for (i, entry) in config.load.into_iter().enumerate() {
+                            self.send(loader::Message::Progress {
+                                n_total,
+                                n_done: i,
+                                config_version,
+                                file: None,
+                            });
                             let watch = config.watch.contains(&i);
                             if watch {
                                 self.watched_entries.push(entry.clone());
                             }
-                            let files = self.load_entry(entry, watch);
+                            let files =
+                                self.load_entry(entry, watch, |file| loader::Message::Progress {
+                                    n_total,
+                                    n_done: i,
+                                    file: Some(file),
+                                    config_version,
+                                });
                             self.send(loader::Message::Loaded { files });
                             self.send(loader::Message::Progress {
                                 n_total,
                                 n_done: i + 1,
                                 config_version,
+                                file: None,
                             });
                         }
                     }
@@ -170,6 +188,7 @@ impl NotifyActor {
         &mut self,
         entry: loader::Entry,
         watch: bool,
+        make_message: impl Fn(AbsPathBuf) -> loader::Message,
     ) -> Vec<(AbsPathBuf, Option<Vec<u8>>)> {
         match entry {
             loader::Entry::Files(files) => files
@@ -186,6 +205,7 @@ impl NotifyActor {
                 let mut res = Vec::new();
 
                 for root in &dirs.include {
+                    self.send(make_message(root.clone()));
                     let walkdir =
                         WalkDir::new(root).follow_links(true).into_iter().filter_entry(|entry| {
                             if !entry.file_type().is_dir() {
@@ -197,9 +217,13 @@ impl NotifyActor {
                         });
 
                     let files = walkdir.filter_map(|it| it.ok()).filter_map(|entry| {
+                        let depth = entry.depth();
                         let is_dir = entry.file_type().is_dir();
                         let is_file = entry.file_type().is_file();
                         let abs_path = AbsPathBuf::assert(entry.into_path());
+                        if depth < 2 && is_dir {
+                            self.send(make_message(abs_path.clone()));
+                        }
                         if is_dir && watch {
                             self.watch(abs_path.clone());
                         }
diff --git a/crates/vfs/src/loader.rs b/crates/vfs/src/loader.rs
index 89a544c81d8..5c507c3dbef 100644
--- a/crates/vfs/src/loader.rs
+++ b/crates/vfs/src/loader.rs
@@ -48,7 +48,16 @@ pub enum Message {
     /// Indicate a gradual progress.
     ///
     /// This is supposed to be the number of loaded files.
-    Progress { n_total: usize, n_done: usize, config_version: u32 },
+    Progress {
+        /// The total files to be loaded.
+        n_total: usize,
+        /// The files that have been loaded successfully.
+        n_done: usize,
+        /// The file being loaded, if any.
+        file: Option<AbsPathBuf>,
+        /// The [`Config`] version.
+        config_version: u32,
+    },
     /// The handle loaded the following files' content.
     Loaded { files: Vec<(AbsPathBuf, Option<Vec<u8>>)> },
     /// The handle loaded the following files' content.
@@ -204,10 +213,11 @@ impl fmt::Debug for Message {
             Message::Changed { files } => {
                 f.debug_struct("Changed").field("n_files", &files.len()).finish()
             }
-            Message::Progress { n_total, n_done, config_version } => f
+            Message::Progress { n_total, n_done, file, config_version } => f
                 .debug_struct("Progress")
                 .field("n_total", n_total)
                 .field("n_done", n_done)
+                .field("file", file)
                 .field("config_version", config_version)
                 .finish(),
         }