diff options
| author | Edwin Cheng <edwin0cheng@gmail.com> | 2022-04-24 11:59:08 +0800 |
|---|---|---|
| committer | Edwin Cheng <edwin0cheng@gmail.com> | 2022-04-24 11:59:08 +0800 |
| commit | 8f616a6cb5cbb7e5ac36505a1d40dca15a905426 (patch) | |
| tree | a4c4fbb688eba70e98dedef2253aa6c7069bd9cf | |
| parent | c61bb6be8c3f45c15a24a26413a665c6c8f63f5c (diff) | |
| download | rust-8f616a6cb5cbb7e5ac36505a1d40dca15a905426.tar.gz rust-8f616a6cb5cbb7e5ac36505a1d40dca15a905426.zip | |
Fix Reload Workspace command
| -rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 7 | ||||
| -rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 13 |
2 files changed, 14 insertions, 6 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index a1b71ab1437..d005cdb9852 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -43,6 +43,13 @@ use crate::{ to_proto, LspError, Result, }; +pub(crate) fn handle_workspace_reload(state: &mut GlobalState, _: ()) -> Result<()> { + state.proc_macro_client = None; + state.fetch_workspaces_queue.request_op("reload workspace request".to_string()); + state.fetch_build_data_queue.request_op("reload workspace request".to_string()); + Ok(()) +} + pub(crate) fn handle_analyzer_status( snap: GlobalStateSnapshot, params: lsp_ext::AnalyzerStatusParams, diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 3ac64e66b52..96f4e2a50b9 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -499,9 +499,13 @@ impl GlobalState { self.fetch_workspaces(cause); } } - if let Some(cause) = self.fetch_build_data_queue.should_start_op() { - self.fetch_build_data(cause); + + if !self.fetch_workspaces_queue.op_in_progress() { + if let Some(cause) = self.fetch_build_data_queue.should_start_op() { + self.fetch_build_data(cause); + } } + if let Some(cause) = self.prime_caches_queue.should_start_op() { tracing::debug!(%cause, "will prime caches"); let num_worker_threads = self.config.prime_caches_num_threads(); @@ -571,14 +575,11 @@ impl GlobalState { } RequestDispatcher { req: Some(req), global_state: self } - .on_sync_mut::<lsp_ext::ReloadWorkspace>(|s, ()| { - s.fetch_workspaces_queue.request_op("reload workspace request".to_string()); - Ok(()) - })? .on_sync_mut::<lsp_types::request::Shutdown>(|s, ()| { s.shutdown_requested = true; Ok(()) })? + .on_sync_mut::<lsp_ext::ReloadWorkspace>(handlers::handle_workspace_reload)? .on_sync_mut::<lsp_ext::MemoryUsage>(handlers::handle_memory_usage)? .on_sync_mut::<lsp_ext::ShuffleCrateGraph>(handlers::handle_shuffle_crate_graph)? .on_sync::<lsp_ext::JoinLines>(handlers::handle_join_lines)? |
