Avoid sending stale diagnostics after sharing a worktree

Co-authored-by: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
Max Brunsfeld 2022-10-12 11:33:19 -07:00
parent cbf31e6d27
commit 3c3671a193
2 changed files with 37 additions and 18 deletions

View file

@ -959,9 +959,20 @@ impl LocalWorktree {
let (snapshots_tx, mut snapshots_rx) = watch::channel_with(self.snapshot());
let rpc = self.client.clone();
let worktree_id = cx.model_id() as u64;
for (path, summary) in self.diagnostic_summaries.iter() {
if let Err(e) = rpc.send(proto::UpdateDiagnosticSummary {
project_id,
worktree_id,
summary: Some(summary.to_proto(&path.0)),
}) {
return Task::ready(Err(e));
}
}
let maintain_remote_snapshot = cx.background().spawn({
let rpc = rpc;
let diagnostic_summaries = self.diagnostic_summaries.clone();
async move {
let mut prev_snapshot = match snapshots_rx.recv().await {
Some(snapshot) => {
@ -994,14 +1005,6 @@ impl LocalWorktree {
}
};
for (path, summary) in diagnostic_summaries.iter() {
rpc.send(proto::UpdateDiagnosticSummary {
project_id,
worktree_id,
summary: Some(summary.to_proto(&path.0)),
})?;
}
while let Some(snapshot) = snapshots_rx.recv().await {
send_worktree_update(
&rpc,