mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
Better account for project reload
This commit is contained in:
parent
c9f878962a
commit
298adb27b9
2 changed files with 8 additions and 6 deletions
|
@ -27,7 +27,7 @@ use crate::{
|
||||||
Result,
|
Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Eq, PartialEq)]
|
#[derive(Eq, PartialEq, Copy, Clone)]
|
||||||
pub(crate) enum Status {
|
pub(crate) enum Status {
|
||||||
Loading,
|
Loading,
|
||||||
Ready,
|
Ready,
|
||||||
|
|
|
@ -136,7 +136,7 @@ impl GlobalState {
|
||||||
log::info!("queued count = {}", queue_count);
|
log::info!("queued count = {}", queue_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut became_ready = false;
|
let prev_status = self.status;
|
||||||
match event {
|
match event {
|
||||||
Event::Lsp(msg) => match msg {
|
Event::Lsp(msg) => match msg {
|
||||||
lsp_server::Message::Request(req) => self.on_request(loop_start, req)?,
|
lsp_server::Message::Request(req) => self.on_request(loop_start, req)?,
|
||||||
|
@ -168,15 +168,17 @@ impl GlobalState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vfs::loader::Message::Progress { n_total, n_done } => {
|
vfs::loader::Message::Progress { n_total, n_done } => {
|
||||||
if n_total > 0 {
|
if n_total == 0 {
|
||||||
|
self.status = Status::Ready;
|
||||||
|
} else {
|
||||||
let state = if n_done == 0 {
|
let state = if n_done == 0 {
|
||||||
|
self.status = Status::Loading;
|
||||||
Progress::Begin
|
Progress::Begin
|
||||||
} else if n_done < n_total {
|
} else if n_done < n_total {
|
||||||
Progress::Report
|
Progress::Report
|
||||||
} else {
|
} else {
|
||||||
assert_eq!(n_done, n_total);
|
assert_eq!(n_done, n_total);
|
||||||
self.status = Status::Ready;
|
self.status = Status::Ready;
|
||||||
became_ready = true;
|
|
||||||
Progress::End
|
Progress::End
|
||||||
};
|
};
|
||||||
self.report_progress(
|
self.report_progress(
|
||||||
|
@ -233,13 +235,13 @@ impl GlobalState {
|
||||||
}
|
}
|
||||||
|
|
||||||
let state_changed = self.process_changes();
|
let state_changed = self.process_changes();
|
||||||
if became_ready {
|
if prev_status == Status::Loading && self.status == Status::Ready {
|
||||||
if let Some(flycheck) = &self.flycheck {
|
if let Some(flycheck) = &self.flycheck {
|
||||||
flycheck.handle.update();
|
flycheck.handle.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.status == Status::Ready && (state_changed || became_ready) {
|
if self.status == Status::Ready && (state_changed || prev_status == Status::Loading) {
|
||||||
let subscriptions = self
|
let subscriptions = self
|
||||||
.mem_docs
|
.mem_docs
|
||||||
.iter()
|
.iter()
|
||||||
|
|
Loading…
Reference in a new issue