From e43811c1645f78818d5d7fe0054b54a462145847 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sat, 8 Aug 2020 21:53:38 +0300 Subject: Fix no inlay hints / unresolved tokens until manual edit No we return ContentModified during the workspace loading. This signifies the language client to retry the operation (i.e. the client will continue polling the server while it returns ContentModified). I believe that there might be cases of overly big projects where the backoff logic we have setup in `sendRequestWithRetry` (which we use for inlay hints) might bail too early (currently the largest retry standby time is 10 seconds). However, I've tried on one of my project with 500+ dependencies and it is still enough. --- crates/rust-analyzer/src/main_loop.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'crates') diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index ceddb2b05..d69f7941d 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -337,6 +337,16 @@ impl GlobalState { fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()> { self.register_request(&req, request_received); + if self.status == Status::Loading { + self.respond(lsp_server::Response::new_err( + req.id, + // FIXME: i32 should impl From (from() guarantees lossless conversion) + lsp_server::ErrorCode::ContentModified as i32, + "Rust Analyzer is still loading...".to_owned(), + )); + return Ok(()); + } + RequestDispatcher { req: Some(req), global_state: self } .on_sync::(|s, ()| Ok(s.fetch_workspaces()))? .on_sync::(|s, p| handlers::handle_join_lines(s.snapshot(), p))? -- cgit v1.2.3