stable sort diagnostics to avoid flickering

pull/6417/head
Pascal Kuthe 10 months ago
parent 839f4d758d
commit 39b3d81abf
No known key found for this signature in database
GPG Key ID: D715E8655AE166A6

@ -771,7 +771,7 @@ impl Application {
// Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order // Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order
params params
.diagnostics .diagnostics
.sort_unstable_by_key(|d| (d.severity, d.range.start)); .sort_by_key(|d| (d.severity, d.range.start));
} }
for source in &lang_conf.persistent_diagnostic_sources { for source in &lang_conf.persistent_diagnostic_sources {
let new_diagnostics = params let new_diagnostics = params
@ -812,9 +812,8 @@ impl Application {
// Sort diagnostics first by severity and then by line numbers. // Sort diagnostics first by severity and then by line numbers.
// Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order // Note: The `lsp::DiagnosticSeverity` enum is already defined in decreasing order
diagnostics.sort_unstable_by_key(|(d, server_id)| { diagnostics
(d.severity, d.range.start, *server_id) .sort_by_key(|(d, server_id)| (d.severity, d.range.start, *server_id));
});
if let Some(doc) = doc { if let Some(doc) = doc {
let diagnostic_of_language_server_and_not_in_unchanged_sources = let diagnostic_of_language_server_and_not_in_unchanged_sources =

@ -99,7 +99,6 @@ impl Serialize for Mode {
serializer.collect_str(self) serializer.collect_str(self)
} }
} }
/// A snapshot of the text of a document that we want to write out to disk /// A snapshot of the text of a document that we want to write out to disk
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct DocumentSavedEvent { pub struct DocumentSavedEvent {
@ -1321,7 +1320,7 @@ impl Document {
true true
}); });
self.diagnostics.sort_unstable_by_key(|diagnostic| { self.diagnostics.sort_by_key(|diagnostic| {
(diagnostic.range, diagnostic.severity, diagnostic.provider) (diagnostic.range, diagnostic.severity, diagnostic.provider)
}); });
@ -1911,9 +1910,8 @@ impl Document {
}); });
} }
self.diagnostics.extend(diagnostics); self.diagnostics.extend(diagnostics);
self.diagnostics.sort_unstable_by_key(|diagnostic| { self.diagnostics
(diagnostic.range, diagnostic.severity, diagnostic.provider) .sort_by_key(|diagnostic| (diagnostic.range, diagnostic.severity, diagnostic.provider));
});
} }
/// clears diagnostics for a given language server id if set, otherwise all diagnostics are cleared /// clears diagnostics for a given language server id if set, otherwise all diagnostics are cleared

Loading…
Cancel
Save