diff options
author | Aleksey Kladov <[email protected]> | 2020-07-02 11:37:04 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-02 14:32:14 +0100 |
commit | 3ef76760761d17cef4ea4e8462d9ee2ca8395467 (patch) | |
tree | dbcb0bf2cc2f43533360a4a16f3994ddb88515df /crates/rust-analyzer/src/main_loop.rs | |
parent | a03cfa49268d3938b55ceff046d04a75de8972b9 (diff) |
Implement StatusBar
Diffstat (limited to 'crates/rust-analyzer/src/main_loop.rs')
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index e03038b25..a5a8c17a0 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -169,16 +169,16 @@ impl GlobalState { | |||
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; | 172 | self.transition(Status::Invalid); |
173 | } else { | 173 | } else { |
174 | let state = if n_done == 0 { | 174 | let state = if n_done == 0 { |
175 | self.status = Status::Loading; | 175 | self.transition(Status::Loading); |
176 | Progress::Begin | 176 | Progress::Begin |
177 | } else if n_done < n_total { | 177 | } else if n_done < n_total { |
178 | Progress::Report | 178 | Progress::Report |
179 | } else { | 179 | } else { |
180 | assert_eq!(n_done, n_total); | 180 | assert_eq!(n_done, n_total); |
181 | self.status = Status::Ready; | 181 | self.transition(Status::Ready); |
182 | Progress::End | 182 | Progress::End |
183 | }; | 183 | }; |
184 | self.report_progress( | 184 | self.report_progress( |
@@ -274,6 +274,18 @@ impl GlobalState { | |||
274 | Ok(()) | 274 | Ok(()) |
275 | } | 275 | } |
276 | 276 | ||
277 | fn transition(&mut self, new_status: Status) { | ||
278 | self.status = Status::Ready; | ||
279 | if self.config.client_caps.status_notification { | ||
280 | let lsp_status = match new_status { | ||
281 | Status::Loading => lsp_ext::Status::Loading, | ||
282 | Status::Ready => lsp_ext::Status::Ready, | ||
283 | Status::Invalid => lsp_ext::Status::Invalid, | ||
284 | }; | ||
285 | self.send_notification::<lsp_ext::StatusNotification>(lsp_status); | ||
286 | } | ||
287 | } | ||
288 | |||
277 | fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()> { | 289 | fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()> { |
278 | self.register_request(&req, request_received); | 290 | self.register_request(&req, request_received); |
279 | 291 | ||