Skip to content

Commit 3cf389f

Browse files
bors[bot]matklad
andauthored
Merge #5171
5171: Better account for project reload r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 3f94ad3 + 298adb2 commit 3cf389f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

crates/rust-analyzer/src/global_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use crate::{
2727
Result,
2828
};
2929

30-
#[derive(Eq, PartialEq)]
30+
#[derive(Eq, PartialEq, Copy, Clone)]
3131
pub(crate) enum Status {
3232
Loading,
3333
Ready,

crates/rust-analyzer/src/main_loop.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl GlobalState {
136136
log::info!("queued count = {}", queue_count);
137137
}
138138

139-
let mut became_ready = false;
139+
let prev_status = self.status;
140140
match event {
141141
Event::Lsp(msg) => match msg {
142142
lsp_server::Message::Request(req) => self.on_request(loop_start, req)?,
@@ -168,15 +168,17 @@ impl GlobalState {
168168
}
169169
}
170170
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 {
172174
let state = if n_done == 0 {
175+
self.status = Status::Loading;
173176
Progress::Begin
174177
} else if n_done < n_total {
175178
Progress::Report
176179
} else {
177180
assert_eq!(n_done, n_total);
178181
self.status = Status::Ready;
179-
became_ready = true;
180182
Progress::End
181183
};
182184
self.report_progress(
@@ -233,13 +235,13 @@ impl GlobalState {
233235
}
234236

235237
let state_changed = self.process_changes();
236-
if became_ready {
238+
if prev_status == Status::Loading && self.status == Status::Ready {
237239
if let Some(flycheck) = &self.flycheck {
238240
flycheck.handle.update();
239241
}
240242
}
241243

242-
if self.status == Status::Ready && (state_changed || became_ready) {
244+
if self.status == Status::Ready && (state_changed || prev_status == Status::Loading) {
243245
let subscriptions = self
244246
.mem_docs
245247
.iter()

0 commit comments

Comments
 (0)