mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Don't retry requests that have already been cancelled
This commit is contained in:
parent
b16b0413dc
commit
1a6c1595fe
7 changed files with 28 additions and 15 deletions
|
@ -35,6 +35,7 @@ impl<I> Incoming<I> {
|
|||
pub fn register(&mut self, id: RequestId, data: I) {
|
||||
self.pending.insert(id, data);
|
||||
}
|
||||
|
||||
pub fn cancel(&mut self, id: RequestId) -> Option<Response> {
|
||||
let _data = self.complete(id.clone())?;
|
||||
let error = ResponseError {
|
||||
|
@ -44,9 +45,14 @@ impl<I> Incoming<I> {
|
|||
};
|
||||
Some(Response { id, result: None, error: Some(error) })
|
||||
}
|
||||
|
||||
pub fn complete(&mut self, id: RequestId) -> Option<I> {
|
||||
self.pending.remove(&id)
|
||||
}
|
||||
|
||||
pub fn is_completed(&self, id: &RequestId) -> bool {
|
||||
!self.pending.contains_key(id)
|
||||
}
|
||||
}
|
||||
|
||||
impl<O> Outgoing<O> {
|
||||
|
@ -56,6 +62,7 @@ impl<O> Outgoing<O> {
|
|||
self.next_id += 1;
|
||||
Request::new(id, method, params)
|
||||
}
|
||||
|
||||
pub fn complete(&mut self, id: RequestId) -> Option<O> {
|
||||
self.pending.remove(&id)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue