# Make LspAdapter::process_diagnostics synchronous \(\#2829\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/7288be4251ba8ef7b7ff967ff6a82988cb613722)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 7288be4251ba8ef7b7ff967ff6a82988cb613722

Requested commit: 7288be4251ba8ef7b7ff967ff6a82988cb613722

Commit: 7288be4251ba8ef7b7ff967ff6a82988cb613722

Tree: 889a32cf402791e58e5350a973439d9749dcdae6

Author: Max Brunsfeld

Committer: GitHub

## Message

```
Make LspAdapter::process_diagnostics synchronous (#2829)

When editing rust code, the project diagnostics view sometimes fails to
update, so that you have to close the view and re-open it to see the
correct state.

This PR fixes one possible cause of that problem. There was an async
step in between *receiving* diagnostics from the language server and
updating the diagnostics, due to an async call to
`LspAdapter::process_diagnostics`. This could cause the following
sequence of events to happen:

1. Rust-analyzer sends us new diagnostics for a file `a.rs`
2. We call `process_diagnostics` with those diagnostics
3. Rust-analyzer sends us a `WorkDoneProgress` message, indicating that
the "flycheck" (aka `cargo check`) process has completed
4. We update the project diagnostics view due to this message.
5. The `process_diagnostics` call for `a.rs` completes
6. 💥 We have the new diagnostics for `a.rs`, but do not update the
project diagnostics view again.

This PR fixes this bug by simply making `process_diagnostics`
synchronous. There is no I/O or expensive computation happening in that
method. If we need to make it asynchronous in the future, we need to
introduce a queue that ensures that `publishDiagnostics` and
`workDoneProgress` messages are processed serially.

Release Notes:

- Fixed a bug where the project diagnostics view would sometimes fail to
update properly when using Rust-analyzer.
```

## Parents

- [d417993c9d287689fae5366496ff09047e3599bd](https://git.cafe/gitcafe/zed/commit/d417993c9d287689fae5366496ff09047e3599bd?format=markdown)

- [4e33654abaafd22de5140cc6e40f342351047a2a](https://git.cafe/gitcafe/zed/commit/4e33654abaafd22de5140cc6e40f342351047a2a?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/7288be4251ba8ef7b7ff967ff6a82988cb613722?format=markdown)
