Merge pull request #2246 from zed-industries/fix-lsp-derive-error

Make diagnostic processing order independent
This commit is contained in:
Mikayla Maki 2023-03-04 02:25:47 -08:00 committed by GitHub
commit 996294ba67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 34 deletions

View file

@ -2538,7 +2538,7 @@ impl Project {
pub fn update_diagnostics(
&mut self,
language_server_id: usize,
params: lsp::PublishDiagnosticsParams,
mut params: lsp::PublishDiagnosticsParams,
disk_based_sources: &[String],
cx: &mut ModelContext<Self>,
) -> Result<()> {
@ -2550,6 +2550,10 @@ impl Project {
let mut primary_diagnostic_group_ids = HashMap::default();
let mut sources_by_group_id = HashMap::default();
let mut supporting_diagnostics = HashMap::default();
// Ensure that primary diagnostics are always the most severe
params.diagnostics.sort_by_key(|item| item.severity);
for diagnostic in &params.diagnostics {
let source = diagnostic.source.as_ref();
let code = diagnostic.code.as_ref().map(|code| match code {