Skip to content

Commit

Permalink
Auto merge of rust-lang#12508 - Veykril:req-retry, r=Veykril
Browse files Browse the repository at this point in the history
fix: Don't respond to cancelled requests when retrying them

Fixes rust-lang/rust-analyzer#12482
  • Loading branch information
bors committed Jun 12, 2022
2 parents ccab003 + ad109f7 commit 604b1c8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/rust-analyzer/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl GlobalState {
let was_quiescent = self.is_quiescent();
match event {
Event::Lsp(msg) => match msg {
lsp_server::Message::Request(req) => self.on_request(loop_start, req),
lsp_server::Message::Request(req) => self.on_new_request(loop_start, req),
lsp_server::Message::Notification(not) => {
self.on_notification(not)?;
}
Expand All @@ -209,7 +209,7 @@ impl GlobalState {
loop {
match task {
Task::Response(response) => self.respond(response),
Task::Retry(req) => self.on_request(loop_start, req),
Task::Retry(req) => self.on_request(req),
Task::Diagnostics(diagnostics_per_file) => {
for (file_id, diagnostics) in diagnostics_per_file {
self.diagnostics.set_native_diagnostics(file_id, diagnostics)
Expand Down Expand Up @@ -555,9 +555,12 @@ impl GlobalState {
Ok(())
}

fn on_request(&mut self, request_received: Instant, req: Request) {
fn on_new_request(&mut self, request_received: Instant, req: Request) {
self.register_request(&req, request_received);
self.on_request(req);
}

fn on_request(&mut self, req: Request) {
if self.shutdown_requested {
self.respond(lsp_server::Response::new_err(
req.id,
Expand Down

0 comments on commit 604b1c8

Please sign in to comment.