From 9cb8ce172d90248c3c50cd2fba64c528c7dbcf7c Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 3 Nov 2023 18:33:17 +0200 Subject: [PATCH 1/3] Refresh diagnostics inside the tab --- Cargo.lock | 1 + crates/diagnostics/Cargo.toml | 1 + crates/diagnostics/src/diagnostics.rs | 5 +++++ crates/editor/src/editor_tests.rs | 2 +- crates/editor/src/items.rs | 4 ++-- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff2a43d99d..e33edf29f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2461,6 +2461,7 @@ dependencies = [ "editor", "gpui", "language", + "log", "lsp", "postage", "project", diff --git a/crates/diagnostics/Cargo.toml b/crates/diagnostics/Cargo.toml index b0b2450f05..26a2a82999 100644 --- a/crates/diagnostics/Cargo.toml +++ b/crates/diagnostics/Cargo.toml @@ -20,6 +20,7 @@ theme = { path = "../theme" } util = { path = "../util" } workspace = { path = "../workspace" } +log.workspace = true anyhow.workspace = true schemars.workspace = true serde.workspace = true diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 0b1c6f8470..865704275b 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -151,6 +151,7 @@ impl ProjectDiagnosticsEditor { ) -> Self { cx.subscribe(&project_handle, |this, _, event, cx| match event { project::Event::DiskBasedDiagnosticsFinished { language_server_id } => { + log::debug!("Disk based diagnostics finished for server {language_server_id}"); this.update_excerpts(Some(*language_server_id), cx); this.update_title(cx); } @@ -158,8 +159,11 @@ impl ProjectDiagnosticsEditor { language_server_id, path, } => { + log::debug!("Adding path {path:?} to update for server {language_server_id}"); this.paths_to_update .insert((path.clone(), *language_server_id)); + this.update_excerpts(Some(*language_server_id), cx); + this.update_title(cx); } _ => {} }) @@ -229,6 +233,7 @@ impl ProjectDiagnosticsEditor { language_server_id: Option, cx: &mut ViewContext, ) { + log::debug!("Updating excerpts for server {language_server_id:?}"); let mut paths = Vec::new(); self.paths_to_update.retain(|(path, server_id)| { if language_server_id diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index feca741737..fc16e52a1b 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -34,7 +34,7 @@ use util::{ test::{marked_text_ranges, marked_text_ranges_by, sample_text, TextRangeMarker}, }; use workspace::{ - item::{FollowableItem, Item, ItemHandle}, + item::{FollowableItem, Item}, NavigationEntry, ViewId, }; diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index c87606070e..1b922848e0 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -33,9 +33,9 @@ use util::{ paths::{PathExt, FILE_ROW_COLUMN_DELIMITER}, ResultExt, TryFutureExt, }; -use workspace::item::{BreadcrumbText, FollowableItemHandle}; +use workspace::item::{BreadcrumbText, FollowableItemHandle, ItemHandle}; use workspace::{ - item::{FollowableItem, Item, ItemEvent, ItemHandle, ProjectItem}, + item::{FollowableItem, Item, ItemEvent, ProjectItem}, searchable::{Direction, SearchEvent, SearchableItem, SearchableItemHandle}, ItemId, ItemNavHistory, Pane, StatusItemView, ToolbarItemLocation, ViewId, Workspace, WorkspaceId, From 6f8947a3d343a3cb8cc178fa7a95aef7ace6652b Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 3 Nov 2023 18:42:37 +0200 Subject: [PATCH 2/3] Fix a compilation error --- crates/editor/src/editor_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rs index fc16e52a1b..feca741737 100644 --- a/crates/editor/src/editor_tests.rs +++ b/crates/editor/src/editor_tests.rs @@ -34,7 +34,7 @@ use util::{ test::{marked_text_ranges, marked_text_ranges_by, sample_text, TextRangeMarker}, }; use workspace::{ - item::{FollowableItem, Item}, + item::{FollowableItem, Item, ItemHandle}, NavigationEntry, ViewId, }; From 918d123284c71fc8f1989e862f7a96a41447fd24 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Fri, 3 Nov 2023 21:51:04 +0200 Subject: [PATCH 3/3] Fix the test --- crates/diagnostics/src/diagnostics.rs | 38 +++++++++++++-------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/crates/diagnostics/src/diagnostics.rs b/crates/diagnostics/src/diagnostics.rs index 865704275b..a3d779531b 100644 --- a/crates/diagnostics/src/diagnostics.rs +++ b/crates/diagnostics/src/diagnostics.rs @@ -1306,25 +1306,6 @@ mod tests { cx, ) .unwrap(); - project - .update_diagnostic_entries( - server_id_2, - PathBuf::from("/test/main.js"), - None, - vec![DiagnosticEntry { - range: Unclipped(PointUtf16::new(1, 0))..Unclipped(PointUtf16::new(1, 1)), - diagnostic: Diagnostic { - message: "warning 1".to_string(), - severity: DiagnosticSeverity::ERROR, - is_primary: true, - is_disk_based: true, - group_id: 2, - ..Default::default() - }, - }], - cx, - ) - .unwrap(); }); // The first language server finishes @@ -1358,6 +1339,25 @@ mod tests { // The second language server finishes project.update(cx, |project, cx| { + project + .update_diagnostic_entries( + server_id_2, + PathBuf::from("/test/main.js"), + None, + vec![DiagnosticEntry { + range: Unclipped(PointUtf16::new(1, 0))..Unclipped(PointUtf16::new(1, 1)), + diagnostic: Diagnostic { + message: "warning 1".to_string(), + severity: DiagnosticSeverity::ERROR, + is_primary: true, + is_disk_based: true, + group_id: 2, + ..Default::default() + }, + }], + cx, + ) + .unwrap(); project.disk_based_diagnostics_finished(server_id_2, cx); });