diff options
author | Edwin Cheng <[email protected]> | 2020-03-29 19:39:03 +0100 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-03-29 19:39:03 +0100 |
commit | 36812b9d7bd42c6469d857c434a63c921b70bdca (patch) | |
tree | d990255b6041036f7d3894a6311dc640268b128a /crates | |
parent | dc0076de12a1e77515c99b08ee74d0af37b250f8 (diff) |
Fix review comments
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 22 | ||||
-rw-r--r-- | crates/rust-analyzer/src/world.rs | 4 |
2 files changed, 13 insertions, 13 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index a96628235..d35963e95 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -208,8 +208,8 @@ pub fn main_loop( | |||
208 | ) | 208 | ) |
209 | }; | 209 | }; |
210 | 210 | ||
211 | loop_state.roots_to_scan = world_state.vfs.read().n_roots(); | 211 | loop_state.roots_total = world_state.vfs.read().n_roots(); |
212 | loop_state.roots_total = loop_state.roots_to_scan; | 212 | loop_state.roots_scanned = 0; |
213 | 213 | ||
214 | let pool = ThreadPool::default(); | 214 | let pool = ThreadPool::default(); |
215 | let (task_sender, task_receiver) = unbounded::<Task>(); | 215 | let (task_sender, task_receiver) = unbounded::<Task>(); |
@@ -337,8 +337,8 @@ struct LoopState { | |||
337 | pending_libraries: Vec<(SourceRootId, Vec<(FileId, RelativePathBuf, Arc<String>)>)>, | 337 | pending_libraries: Vec<(SourceRootId, Vec<(FileId, RelativePathBuf, Arc<String>)>)>, |
338 | workspace_loaded: bool, | 338 | workspace_loaded: bool, |
339 | 339 | ||
340 | roots_scanned_progress: Option<usize>, | 340 | roots_progress_reported: Option<usize>, |
341 | roots_to_scan: usize, | 341 | roots_scanned: usize, |
342 | roots_total: usize, | 342 | roots_total: usize, |
343 | } | 343 | } |
344 | 344 | ||
@@ -383,7 +383,7 @@ fn loop_turn( | |||
383 | world_state.add_lib(lib); | 383 | world_state.add_lib(lib); |
384 | world_state.maybe_collect_garbage(); | 384 | world_state.maybe_collect_garbage(); |
385 | loop_state.in_flight_libraries -= 1; | 385 | loop_state.in_flight_libraries -= 1; |
386 | loop_state.roots_to_scan -= 1; | 386 | loop_state.roots_scanned += 1; |
387 | } | 387 | } |
388 | Event::CheckWatcher(task) => on_check_task(task, world_state, task_sender)?, | 388 | Event::CheckWatcher(task) => on_check_task(task, world_state, task_sender)?, |
389 | Event::Msg(msg) => match msg { | 389 | Event::Msg(msg) => match msg { |
@@ -415,7 +415,7 @@ fn loop_turn( | |||
415 | }; | 415 | }; |
416 | 416 | ||
417 | let mut state_changed = false; | 417 | let mut state_changed = false; |
418 | if let Some(changes) = world_state.process_changes(&mut loop_state.roots_to_scan) { | 418 | if let Some(changes) = world_state.process_changes(&mut loop_state.roots_scanned) { |
419 | state_changed = true; | 419 | state_changed = true; |
420 | loop_state.pending_libraries.extend(changes); | 420 | loop_state.pending_libraries.extend(changes); |
421 | } | 421 | } |
@@ -438,7 +438,7 @@ fn loop_turn( | |||
438 | && world_state.feature_flags.get("notifications.workspace-loaded"); | 438 | && world_state.feature_flags.get("notifications.workspace-loaded"); |
439 | 439 | ||
440 | if !loop_state.workspace_loaded | 440 | if !loop_state.workspace_loaded |
441 | && loop_state.roots_to_scan == 0 | 441 | && loop_state.roots_scanned == loop_state.roots_total |
442 | && loop_state.pending_libraries.is_empty() | 442 | && loop_state.pending_libraries.is_empty() |
443 | && loop_state.in_flight_libraries == 0 | 443 | && loop_state.in_flight_libraries == 0 |
444 | { | 444 | { |
@@ -719,11 +719,11 @@ fn on_diagnostic_task(task: DiagnosticTask, msg_sender: &Sender<Message>, state: | |||
719 | 719 | ||
720 | fn send_startup_progress(sender: &Sender<Message>, loop_state: &mut LoopState) { | 720 | fn send_startup_progress(sender: &Sender<Message>, loop_state: &mut LoopState) { |
721 | let total: usize = loop_state.roots_total; | 721 | let total: usize = loop_state.roots_total; |
722 | let prev_progress = loop_state.roots_scanned_progress; | 722 | let prev = loop_state.roots_progress_reported; |
723 | let progress = total - loop_state.roots_to_scan; | 723 | let progress = loop_state.roots_scanned; |
724 | loop_state.roots_scanned_progress = Some(progress); | 724 | loop_state.roots_progress_reported = Some(progress); |
725 | 725 | ||
726 | match (prev_progress, loop_state.workspace_loaded) { | 726 | match (prev, loop_state.workspace_loaded) { |
727 | (None, false) => { | 727 | (None, false) => { |
728 | let work_done_progress_create = request_new::<req::WorkDoneProgressCreate>( | 728 | let work_done_progress_create = request_new::<req::WorkDoneProgressCreate>( |
729 | loop_state.next_request_id(), | 729 | loop_state.next_request_id(), |
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs index 01008b09f..5680397ed 100644 --- a/crates/rust-analyzer/src/world.rs +++ b/crates/rust-analyzer/src/world.rs | |||
@@ -203,7 +203,7 @@ impl WorldState { | |||
203 | /// FIXME: better API here | 203 | /// FIXME: better API here |
204 | pub fn process_changes( | 204 | pub fn process_changes( |
205 | &mut self, | 205 | &mut self, |
206 | roots_to_scan: &mut usize, | 206 | roots_scanned: &mut usize, |
207 | ) -> Option<Vec<(SourceRootId, Vec<(FileId, RelativePathBuf, Arc<String>)>)>> { | 207 | ) -> Option<Vec<(SourceRootId, Vec<(FileId, RelativePathBuf, Arc<String>)>)>> { |
208 | let changes = self.vfs.write().commit_changes(); | 208 | let changes = self.vfs.write().commit_changes(); |
209 | if changes.is_empty() { | 209 | if changes.is_empty() { |
@@ -217,7 +217,7 @@ impl WorldState { | |||
217 | let root_path = self.vfs.read().root2path(root); | 217 | let root_path = self.vfs.read().root2path(root); |
218 | let is_local = self.roots.iter().any(|r| root_path.starts_with(r)); | 218 | let is_local = self.roots.iter().any(|r| root_path.starts_with(r)); |
219 | if is_local { | 219 | if is_local { |
220 | *roots_to_scan -= 1; | 220 | *roots_scanned += 1; |
221 | for (file, path, text) in files { | 221 | for (file, path, text) in files { |
222 | change.add_file(SourceRootId(root.0), FileId(file.0), path, text); | 222 | change.add_file(SourceRootId(root.0), FileId(file.0), path, text); |
223 | } | 223 | } |