Revert "Don't replace newer diagnostics with older ones"

This reverts commit 71eeeedc05.
This commit is contained in:
Antonio Scandurra 2022-11-17 16:57:40 +01:00
parent e7e45be6e1
commit 4f39181c4c
7 changed files with 13 additions and 33 deletions

View file

@ -366,7 +366,6 @@ impl Worktree {
Worktree::Remote(worktree) => &worktree.diagnostic_summaries,
}
.iter()
.filter(|(_, summary)| !summary.is_empty())
.map(|(path, summary)| (path.0.clone(), *summary))
}
@ -517,8 +516,7 @@ impl LocalWorktree {
.diagnostic_summaries
.remove(&PathKey(worktree_path.clone()))
.unwrap_or_default();
let new_summary =
DiagnosticSummary::new(language_server_id, old_summary.version + 1, &diagnostics);
let new_summary = DiagnosticSummary::new(language_server_id, &diagnostics);
if !new_summary.is_empty() {
self.diagnostic_summaries
.insert(PathKey(worktree_path.clone()), new_summary);
@ -1108,17 +1106,15 @@ impl RemoteWorktree {
path: Arc<Path>,
summary: &proto::DiagnosticSummary,
) {
let old_summary = self.diagnostic_summaries.get(&PathKey(path.clone()));
let new_summary = DiagnosticSummary {
let summary = DiagnosticSummary {
language_server_id: summary.language_server_id as usize,
error_count: summary.error_count as usize,
warning_count: summary.warning_count as usize,
version: summary.version as usize,
};
if old_summary.map_or(true, |old_summary| {
new_summary.version >= old_summary.version
}) {
self.diagnostic_summaries.insert(PathKey(path), new_summary);
if summary.is_empty() {
self.diagnostic_summaries.remove(&PathKey(path));
} else {
self.diagnostic_summaries.insert(PathKey(path), summary);
}
}