@@ -721,7 +721,7 @@ impl Application {
721721 ));
722722 }
723723 }
724− Notification::PublishDiagnostics(mut params) => {
724+ Notification::PublishDiagnostics(params) => {
725725 let path = match params.uri.to_file_path() {
726726 Ok(path) => path,
727727 Err(_) => {
@@ -841,15 +841,10 @@ impl Application {
841841 doc.replace_diagnostics(diagnostics, server_id);
842842 }
843843
844− // Sort diagnostics first by severity and then by line numbers.
845− // Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order
846− params
847− .diagnostics
848− .sort_unstable_by_key(|d| (d.severity, d.range.start));
849− let diagnostics = params
844+ let mut diagnostics = params
850845 .diagnostics
851846 .into_iter()
852− .map(|d| (d, server_id, offset_encoding))
847+ .map(|d| (d, server_id))
853848 .collect();
854849
855850 // Insert the original lsp::Diagnostics here because we may have no open document
@@ -859,10 +854,16 @@ impl Application {
859854 Entry::Occupied(o) => {
860855 let current_diagnostics = o.into_mut();
861856 // there may entries of other language servers, which is why we can't overwrite the whole entry
862− current_diagnostics.retain(|(_, lsp_id, _)| *lsp_id != server_id);
863− current_diagnostics.extend(diagnostics);
857+ current_diagnostics.retain(|(_, lsp_id)| *lsp_id != server_id);
858+ current_diagnostics.append(&mut diagnostics);
859+ // Sort diagnostics first by severity and then by line numbers.
860+ // Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order
861+ current_diagnostics
862+ .sort_unstable_by_key(|(d, _)| (d.severity, d.range.start));
864863 }
865864 Entry::Vacant(v) => {
865+ diagnostics
866+ .sort_unstable_by_key(|(d, _)| (d.severity, d.range.start));
866867 v.insert(diagnostics);
867868 }
868869 };