From 4f39181c4cbd7b1845aa9ec3ff0fea59c80d4c86 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 17 Nov 2022 16:57:40 +0100 Subject: [PATCH] Revert "Don't replace newer diagnostics with older ones" This reverts commit 71eeeedc05f7ed6978f2ebfc6f169a7bc9cc8907. --- .../20221109000000_test_schema.sql | 1 - .../20221111092550_reconnection_support.sql | 1 - crates/collab/src/db.rs | 11 +++-------- crates/collab/src/integration_tests.rs | 12 ++++-------- crates/project/src/project.rs | 4 ---- crates/project/src/worktree.rs | 16 ++++++---------- crates/rpc/proto/zed.proto | 1 - 7 files changed, 13 insertions(+), 33 deletions(-) diff --git a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql index bb216eb32d..66925fddd5 100644 --- a/crates/collab/migrations.sqlite/20221109000000_test_schema.sql +++ b/crates/collab/migrations.sqlite/20221109000000_test_schema.sql @@ -82,7 +82,6 @@ CREATE TABLE "worktree_diagnostic_summaries" ( "language_server_id" INTEGER NOT NULL, "error_count" INTEGER NOT NULL, "warning_count" INTEGER NOT NULL, - "version" INTEGER NOT NULL, PRIMARY KEY(project_id, worktree_id, path), FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE ); diff --git a/crates/collab/migrations/20221111092550_reconnection_support.sql b/crates/collab/migrations/20221111092550_reconnection_support.sql index de29f0c878..2b8f7824cb 100644 --- a/crates/collab/migrations/20221111092550_reconnection_support.sql +++ b/crates/collab/migrations/20221111092550_reconnection_support.sql @@ -44,7 +44,6 @@ CREATE TABLE "worktree_diagnostic_summaries" ( "language_server_id" INTEGER NOT NULL, "error_count" INTEGER NOT NULL, "warning_count" INTEGER NOT NULL, - "version" INTEGER NOT NULL, PRIMARY KEY(project_id, worktree_id, path), FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE ); diff --git a/crates/collab/src/db.rs b/crates/collab/src/db.rs index 55c71ea92e..c97c82c656 100644 --- a/crates/collab/src/db.rs +++ b/crates/collab/src/db.rs @@ -1809,15 +1809,13 @@ where path, language_server_id, error_count, - warning_count, - version + warning_count ) - VALUES ($1, $2, $3, $4, $5, $6, $7) + VALUES ($1, $2, $3, $4, $5, $6) ON CONFLICT (project_id, worktree_id, path) DO UPDATE SET language_server_id = excluded.language_server_id, error_count = excluded.error_count, - warning_count = excluded.warning_count, - version = excluded.version + warning_count = excluded.warning_count ", ) .bind(project_id) @@ -1826,7 +1824,6 @@ where .bind(summary.language_server_id as i64) .bind(summary.error_count as i32) .bind(summary.warning_count as i32) - .bind(summary.version as i32) .execute(&mut tx) .await?; @@ -2041,7 +2038,6 @@ where language_server_id: summary.language_server_id as u64, error_count: summary.error_count as u32, warning_count: summary.warning_count as u32, - version: summary.version as u32, }); } } @@ -2666,7 +2662,6 @@ struct WorktreeDiagnosticSummary { language_server_id: i64, error_count: i32, warning_count: i32, - version: i32, } id_type!(LanguageServerId); diff --git a/crates/collab/src/integration_tests.rs b/crates/collab/src/integration_tests.rs index d730b5d4e7..1236af42cb 100644 --- a/crates/collab/src/integration_tests.rs +++ b/crates/collab/src/integration_tests.rs @@ -2412,10 +2412,9 @@ async fn test_collaborating_with_diagnostics( path: Arc::from(Path::new("a.rs")), }, DiagnosticSummary { - language_server_id: 0, error_count: 1, warning_count: 0, - version: 2, + ..Default::default() }, )] ) @@ -2445,10 +2444,9 @@ async fn test_collaborating_with_diagnostics( path: Arc::from(Path::new("a.rs")), }, DiagnosticSummary { - language_server_id: 0, error_count: 1, warning_count: 0, - version: 2, + ..Default::default() }, )] ); @@ -2486,10 +2484,9 @@ async fn test_collaborating_with_diagnostics( path: Arc::from(Path::new("a.rs")), }, DiagnosticSummary { - language_server_id: 0, error_count: 1, warning_count: 1, - version: 3, + ..Default::default() }, )] ); @@ -2503,10 +2500,9 @@ async fn test_collaborating_with_diagnostics( path: Arc::from(Path::new("a.rs")), }, DiagnosticSummary { - language_server_id: 0, error_count: 1, warning_count: 1, - version: 3, + ..Default::default() }, )] ); diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 9d7323f989..503ae8d4b2 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -223,7 +223,6 @@ pub struct DiagnosticSummary { pub language_server_id: usize, pub error_count: usize, pub warning_count: usize, - pub version: usize, } #[derive(Debug, Clone)] @@ -294,14 +293,12 @@ pub struct ProjectTransaction(pub HashMap, language::Transac impl DiagnosticSummary { fn new<'a, T: 'a>( language_server_id: usize, - version: usize, diagnostics: impl IntoIterator>, ) -> Self { let mut this = Self { language_server_id, error_count: 0, warning_count: 0, - version, }; for entry in diagnostics { @@ -327,7 +324,6 @@ impl DiagnosticSummary { language_server_id: self.language_server_id as u64, error_count: self.error_count as u32, warning_count: self.warning_count as u32, - version: self.version as u32, } } } diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 04e77cf09a..836ac55b66 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -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, 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); } } diff --git a/crates/rpc/proto/zed.proto b/crates/rpc/proto/zed.proto index b6d4b83b3b..30c1c89e8f 100644 --- a/crates/rpc/proto/zed.proto +++ b/crates/rpc/proto/zed.proto @@ -652,7 +652,6 @@ message DiagnosticSummary { uint64 language_server_id = 2; uint32 error_count = 3; uint32 warning_count = 4; - uint32 version = 5; } message UpdateLanguageServer {