Send guests DiskBasedDiagnosticsFinished messages when they join a project
Co-authored-by: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
parent
3c3671a193
commit
69dcfbb423
3 changed files with 52 additions and 27 deletions
|
@ -2161,9 +2161,8 @@ async fn test_collaborating_with_diagnostics(
|
||||||
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await;
|
let (project_a, worktree_id) = client_a.build_local_project("/a", cx_a).await;
|
||||||
|
|
||||||
// Cause the language server to start.
|
// Cause the language server to start.
|
||||||
let _buffer = cx_a
|
let _buffer = project_a
|
||||||
.background()
|
.update(cx_a, |project, cx| {
|
||||||
.spawn(project_a.update(cx_a, |project, cx| {
|
|
||||||
project.open_buffer(
|
project.open_buffer(
|
||||||
ProjectPath {
|
ProjectPath {
|
||||||
worktree_id,
|
worktree_id,
|
||||||
|
@ -2171,7 +2170,7 @@ async fn test_collaborating_with_diagnostics(
|
||||||
},
|
},
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
}))
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@ -2245,10 +2244,22 @@ async fn test_collaborating_with_diagnostics(
|
||||||
|
|
||||||
// Join project as client C and observe the diagnostics.
|
// Join project as client C and observe the diagnostics.
|
||||||
let project_c = client_c.build_remote_project(project_id, cx_c).await;
|
let project_c = client_c.build_remote_project(project_id, cx_c).await;
|
||||||
|
let project_c_diagnostic_summaries = Rc::new(RefCell::new(Vec::new()));
|
||||||
|
project_c.update(cx_c, |_, cx| {
|
||||||
|
let summaries = project_c_diagnostic_summaries.clone();
|
||||||
|
cx.subscribe(&project_c, {
|
||||||
|
move |p, _, event, cx| {
|
||||||
|
if let project::Event::DiskBasedDiagnosticsFinished { .. } = event {
|
||||||
|
*summaries.borrow_mut() = p.diagnostic_summaries(cx).collect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
});
|
||||||
|
|
||||||
deterministic.run_until_parked();
|
deterministic.run_until_parked();
|
||||||
project_c.read_with(cx_c, |project, cx| {
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
project.diagnostic_summaries(cx).collect::<Vec<_>>(),
|
project_c_diagnostic_summaries.borrow().as_slice(),
|
||||||
&[(
|
&[(
|
||||||
ProjectPath {
|
ProjectPath {
|
||||||
worktree_id,
|
worktree_id,
|
||||||
|
@ -2260,8 +2271,7 @@ async fn test_collaborating_with_diagnostics(
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
)
|
);
|
||||||
});
|
|
||||||
|
|
||||||
// Simulate a language server reporting more errors for a file.
|
// Simulate a language server reporting more errors for a file.
|
||||||
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
fake_language_server.notify::<lsp::notification::PublishDiagnostics>(
|
||||||
|
|
|
@ -1012,6 +1012,21 @@ impl Server {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for language_server in &project.language_servers {
|
||||||
|
self.peer.send(
|
||||||
|
request.sender_id,
|
||||||
|
proto::UpdateLanguageServer {
|
||||||
|
project_id: project_id.to_proto(),
|
||||||
|
language_server_id: language_server.id,
|
||||||
|
variant: Some(
|
||||||
|
proto::update_language_server::Variant::DiskBasedDiagnosticsUpdated(
|
||||||
|
proto::LspDiskBasedDiagnosticsUpdated {},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1084,13 +1084,6 @@ impl Project {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for worktree in self.worktrees(cx).collect::<Vec<_>>() {
|
|
||||||
worktree.update(cx, |worktree, cx| {
|
|
||||||
let worktree = worktree.as_local_mut().unwrap();
|
|
||||||
worktree_share_tasks.push(worktree.share(project_id, cx));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (server_id, status) in &self.language_server_statuses {
|
for (server_id, status) in &self.language_server_statuses {
|
||||||
self.client
|
self.client
|
||||||
.send(proto::StartLanguageServer {
|
.send(proto::StartLanguageServer {
|
||||||
|
@ -1103,6 +1096,13 @@ impl Project {
|
||||||
.log_err();
|
.log_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for worktree in self.worktrees(cx).collect::<Vec<_>>() {
|
||||||
|
worktree.update(cx, |worktree, cx| {
|
||||||
|
let worktree = worktree.as_local_mut().unwrap();
|
||||||
|
worktree_share_tasks.push(worktree.share(project_id, cx));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
self.client_subscriptions
|
self.client_subscriptions
|
||||||
.push(self.client.add_model_for_remote_entity(project_id, cx));
|
.push(self.client.add_model_for_remote_entity(project_id, cx));
|
||||||
self.metadata_changed(cx);
|
self.metadata_changed(cx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue