Omit worktree id when emitting Event::DiskBasedDiagnosticsUpdated
Sometimes we will have more than one worktree associated with the same language server and in that case it's unclear which worktree id we should report an event for.
This commit is contained in:
parent
71082d4cdc
commit
6b1f989c2b
4 changed files with 30 additions and 53 deletions
|
@ -14,7 +14,7 @@ use gpui::{
|
|||
};
|
||||
use language::{Bias, Buffer, Diagnostic, DiagnosticEntry, Point, Selection, SelectionGoal};
|
||||
use postage::watch;
|
||||
use project::{Project, ProjectPath, WorktreeId};
|
||||
use project::{Project, ProjectPath};
|
||||
use std::{cmp::Ordering, mem, ops::Range, path::PathBuf, rc::Rc, sync::Arc};
|
||||
use util::TryFutureExt;
|
||||
use workspace::{NavHistory, Workspace};
|
||||
|
@ -49,7 +49,7 @@ struct ProjectDiagnosticsEditor {
|
|||
editor: ViewHandle<Editor>,
|
||||
excerpts: ModelHandle<MultiBuffer>,
|
||||
path_states: Vec<PathState>,
|
||||
paths_to_update: HashMap<WorktreeId, BTreeSet<ProjectPath>>,
|
||||
paths_to_update: BTreeSet<ProjectPath>,
|
||||
build_settings: BuildSettings,
|
||||
settings: watch::Receiver<workspace::Settings>,
|
||||
}
|
||||
|
@ -119,16 +119,12 @@ impl ProjectDiagnosticsEditor {
|
|||
) -> Self {
|
||||
let project = model.read(cx).project.clone();
|
||||
cx.subscribe(&project, |this, _, event, cx| match event {
|
||||
project::Event::DiskBasedDiagnosticsUpdated { worktree_id } => {
|
||||
if let Some(paths) = this.paths_to_update.remove(&worktree_id) {
|
||||
this.update_excerpts(paths, cx);
|
||||
}
|
||||
project::Event::DiskBasedDiagnosticsFinished => {
|
||||
let paths = mem::take(&mut this.paths_to_update);
|
||||
this.update_excerpts(paths, cx);
|
||||
}
|
||||
project::Event::DiagnosticsUpdated(path) => {
|
||||
this.paths_to_update
|
||||
.entry(path.worktree_id)
|
||||
.or_default()
|
||||
.insert(path.clone());
|
||||
this.paths_to_update.insert(path.clone());
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
|
@ -909,7 +905,7 @@ mod tests {
|
|||
worktree_id,
|
||||
path: Arc::from("/test/consts.rs".as_ref()),
|
||||
}));
|
||||
cx.emit(project::Event::DiskBasedDiagnosticsUpdated { worktree_id });
|
||||
cx.emit(project::Event::DiskBasedDiagnosticsFinished);
|
||||
});
|
||||
|
||||
view.next_notification(&cx).await;
|
||||
|
@ -1029,7 +1025,7 @@ mod tests {
|
|||
worktree_id,
|
||||
path: Arc::from("/test/consts.rs".as_ref()),
|
||||
}));
|
||||
cx.emit(project::Event::DiskBasedDiagnosticsUpdated { worktree_id });
|
||||
cx.emit(project::Event::DiskBasedDiagnosticsFinished);
|
||||
});
|
||||
|
||||
view.next_notification(&cx).await;
|
||||
|
|
|
@ -19,7 +19,7 @@ impl DiagnosticSummary {
|
|||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
cx.subscribe(project, |this, project, event, cx| match event {
|
||||
project::Event::DiskBasedDiagnosticsUpdated { .. } => {
|
||||
project::Event::DiskBasedDiagnosticsUpdated => {
|
||||
this.summary = project.read(cx).diagnostic_summary(cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue