Don't clobber diagnostics when getting new snapshot from background scanner

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2022-01-06 15:04:06 -08:00
parent 7357b3ff2a
commit 9bbe67f0ea

View file

@ -34,6 +34,7 @@ use std::{
ffi::{OsStr, OsString},
fmt,
future::Future,
mem,
ops::{Deref, Range},
path::{Path, PathBuf},
sync::{
@ -583,7 +584,9 @@ impl Worktree {
match self {
Self::Local(worktree) => {
let is_fake_fs = worktree.fs.is_fake();
worktree.snapshot = worktree.background_snapshot.lock().clone();
worktree
.snapshot
.assign(worktree.background_snapshot.lock().clone());
if worktree.is_scanning() {
if worktree.poll_task.is_none() {
worktree.poll_task = Some(cx.spawn(|this, mut cx| async move {
@ -1842,6 +1845,14 @@ impl Snapshot {
Ok(())
}
fn assign(&mut self, mut other: Self) {
mem::swap(
&mut self.diagnostic_summaries,
&mut other.diagnostic_summaries,
);
*self = other;
}
pub fn file_count(&self) -> usize {
self.entries_by_path.summary().file_count
}