diff options
-rw-r--r-- | crates/rust-analyzer/src/global_state.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index b8aa1e5b5..b7b4edf66 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs | |||
@@ -27,7 +27,7 @@ use crate::{ | |||
27 | Result, | 27 | Result, |
28 | }; | 28 | }; |
29 | 29 | ||
30 | #[derive(Eq, PartialEq)] | 30 | #[derive(Eq, PartialEq, Copy, Clone)] |
31 | pub(crate) enum Status { | 31 | pub(crate) enum Status { |
32 | Loading, | 32 | Loading, |
33 | Ready, | 33 | Ready, |
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index e3d49d24d..e03038b25 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -136,7 +136,7 @@ impl GlobalState { | |||
136 | log::info!("queued count = {}", queue_count); | 136 | log::info!("queued count = {}", queue_count); |
137 | } | 137 | } |
138 | 138 | ||
139 | let mut became_ready = false; | 139 | let prev_status = self.status; |
140 | match event { | 140 | match event { |
141 | Event::Lsp(msg) => match msg { | 141 | Event::Lsp(msg) => match msg { |
142 | lsp_server::Message::Request(req) => self.on_request(loop_start, req)?, | 142 | lsp_server::Message::Request(req) => self.on_request(loop_start, req)?, |
@@ -168,15 +168,17 @@ impl GlobalState { | |||
168 | } | 168 | } |
169 | } | 169 | } |
170 | vfs::loader::Message::Progress { n_total, n_done } => { | 170 | vfs::loader::Message::Progress { n_total, n_done } => { |
171 | if n_total > 0 { | 171 | if n_total == 0 { |
172 | self.status = Status::Ready; | ||
173 | } else { | ||
172 | let state = if n_done == 0 { | 174 | let state = if n_done == 0 { |
175 | self.status = Status::Loading; | ||
173 | Progress::Begin | 176 | Progress::Begin |
174 | } else if n_done < n_total { | 177 | } else if n_done < n_total { |
175 | Progress::Report | 178 | Progress::Report |
176 | } else { | 179 | } else { |
177 | assert_eq!(n_done, n_total); | 180 | assert_eq!(n_done, n_total); |
178 | self.status = Status::Ready; | 181 | self.status = Status::Ready; |
179 | became_ready = true; | ||
180 | Progress::End | 182 | Progress::End |
181 | }; | 183 | }; |
182 | self.report_progress( | 184 | self.report_progress( |
@@ -233,13 +235,13 @@ impl GlobalState { | |||
233 | } | 235 | } |
234 | 236 | ||
235 | let state_changed = self.process_changes(); | 237 | let state_changed = self.process_changes(); |
236 | if became_ready { | 238 | if prev_status == Status::Loading && self.status == Status::Ready { |
237 | if let Some(flycheck) = &self.flycheck { | 239 | if let Some(flycheck) = &self.flycheck { |
238 | flycheck.handle.update(); | 240 | flycheck.handle.update(); |
239 | } | 241 | } |
240 | } | 242 | } |
241 | 243 | ||
242 | if self.status == Status::Ready && (state_changed || became_ready) { | 244 | if self.status == Status::Ready && (state_changed || prev_status == Status::Loading) { |
243 | let subscriptions = self | 245 | let subscriptions = self |
244 | .mem_docs | 246 | .mem_docs |
245 | .iter() | 247 | .iter() |