mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
parent
51ac6de6f3
commit
1ceb2ea414
4 changed files with 54 additions and 7 deletions
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue