Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix stale pull diagnostics for open buffers (#46201)

John Turc38dc0ad27a4
diff --git a/crates/collab/src/tests/editor_tests.rs b/crates/collab/src/tests/editor_tests.rs
index 4e6cdb0e79a..8796ed0b0c4 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 c63a47e3b59..7b114820d25 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