Emit an UpdateDiagnostics
from Worktree when buffer diagnostics change
This commit is contained in:
parent
c47340000d
commit
9164c5f239
3 changed files with 34 additions and 11 deletions
|
@ -1097,15 +1097,43 @@ impl LocalWorktree {
|
|||
buffer
|
||||
});
|
||||
|
||||
this.update(&mut cx, |this, _| {
|
||||
this.update(&mut cx, |this, cx| {
|
||||
let this = this.as_local_mut().unwrap();
|
||||
this.open_buffers.insert(buffer.id(), buffer.downgrade());
|
||||
cx.subscribe(&buffer, |worktree, buffer, event, cx| {
|
||||
worktree
|
||||
.as_local_mut()
|
||||
.unwrap()
|
||||
.on_buffer_event(buffer, event, cx);
|
||||
})
|
||||
.detach();
|
||||
});
|
||||
|
||||
Ok(buffer)
|
||||
})
|
||||
}
|
||||
|
||||
fn on_buffer_event(
|
||||
&mut self,
|
||||
buffer: ModelHandle<Buffer>,
|
||||
event: &language::Event,
|
||||
cx: &mut ModelContext<Worktree>,
|
||||
) {
|
||||
match event {
|
||||
language::Event::DiagnosticsUpdated => {
|
||||
let buffer = buffer.read(cx);
|
||||
if let Some(path) = buffer.file().map(|file| file.path().clone()) {
|
||||
let diagnostics = buffer.all_diagnostics();
|
||||
self.diagnostic_summaries
|
||||
.insert(path.clone(), DiagnosticSummary::new(diagnostics));
|
||||
cx.emit(Event::DiagnosticsUpdated(path));
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn open_remote_buffer(
|
||||
&mut self,
|
||||
envelope: TypedEnvelope<proto::OpenBuffer>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue