From c38dc0ad27a4c1b1254e16c48b7a3309baccf1b1 Mon Sep 17 00:00:00 2001 From: John Tur Date: Tue, 6 Jan 2026 18:57:25 -0500 Subject: [PATCH] Fix stale pull diagnostics for open buffers (#46201) Release Notes: - N/A --- crates/collab/src/tests/editor_tests.rs | 17 ++++++++++------- crates/editor/src/editor.rs | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/collab/src/tests/editor_tests.rs b/crates/collab/src/tests/editor_tests.rs index 4e6cdb0e79aba494bd01137cc262a097a084217e..8796ed0b0c480cf92d7b808db815f9561059677a 100644 --- a/crates/collab/src/tests/editor_tests.rs +++ b/crates/collab/src/tests/editor_tests.rs @@ -3295,10 +3295,11 @@ async fn test_lsp_pull_diagnostics( editor.handle_input(":", window, cx); }); pull_diagnostics_handle.next().await.unwrap(); + pull_diagnostics_handle.next().await.unwrap(); assert_eq!( - 4, + 5, diagnostics_pulls_made.load(atomic::Ordering::Acquire), - "Client lib.rs edits should trigger another diagnostics pull for a buffer" + "Client lib.rs edits should trigger another diagnostics pull for open buffers" ); workspace_diagnostics_pulls_handle.next().await.unwrap(); assert_eq!( @@ -3314,10 +3315,11 @@ async fn test_lsp_pull_diagnostics( }); pull_diagnostics_handle.next().await.unwrap(); pull_diagnostics_handle.next().await.unwrap(); + pull_diagnostics_handle.next().await.unwrap(); assert_eq!( - 6, + 8, diagnostics_pulls_made.load(atomic::Ordering::Acquire), - "Client main.rs edits should trigger another diagnostics pull by both client and host as they share the buffer" + "Client main.rs edits should trigger diagnostics pull by both client and host and an extra pull for the client's lib.rs" ); workspace_diagnostics_pulls_handle.next().await.unwrap(); assert_eq!( @@ -3333,10 +3335,11 @@ async fn test_lsp_pull_diagnostics( }); pull_diagnostics_handle.next().await.unwrap(); pull_diagnostics_handle.next().await.unwrap(); + pull_diagnostics_handle.next().await.unwrap(); assert_eq!( - 8, + 11, diagnostics_pulls_made.load(atomic::Ordering::Acquire), - "Host main.rs edits should trigger another diagnostics pull by both client and host as they share the buffer" + "Host main.rs edits should trigger another diagnostics pull by both client and host and another pull for the client's lib.rs" ); workspace_diagnostics_pulls_handle.next().await.unwrap(); assert_eq!( @@ -3364,7 +3367,7 @@ async fn test_lsp_pull_diagnostics( .into_response() .expect("workspace diagnostics refresh request failed"); assert_eq!( - 8, + 11, diagnostics_pulls_made.load(atomic::Ordering::Acquire), "No single file pulls should happen after the diagnostics refresh server request" ); diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index c63a47e3b599d1c3a667464fc0ffa90336bda79e..7b114820d252f7cd4c5a1ccac2ae10fc73cfb092 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -18952,7 +18952,7 @@ impl Editor { if already_used_buffers.insert(buffer_id) { if let Some(worktree_id) = buffer.file().map(|f| f.worktree_id(cx)) { return !edited_buffer_ids.contains(&buffer_id) - && !edited_worktree_ids.contains(&worktree_id); + && edited_worktree_ids.contains(&worktree_id); } } false