Run Project::diagnose when registering a new language on Worktree

This commit is contained in:
Antonio Scandurra 2022-01-03 16:58:36 +01:00
parent 2b31a48ef9
commit 496066db59
2 changed files with 6 additions and 1 deletions

View file

@ -475,7 +475,10 @@ impl Project {
fn add_worktree(&mut self, worktree: ModelHandle<Worktree>, cx: &mut ModelContext<Self>) {
cx.observe(&worktree, |_, _, cx| cx.notify()).detach();
cx.subscribe(&worktree, |_, worktree, event, cx| match event {
cx.subscribe(&worktree, |this, worktree, event, cx| match event {
worktree::Event::LanguageRegistered => {
this.diagnose(cx);
}
worktree::Event::DiagnosticsUpdated(path) => {
cx.emit(Event::DiagnosticsUpdated(ProjectPath {
worktree_id: worktree.id(),

View file

@ -68,6 +68,7 @@ pub enum Worktree {
#[derive(Debug)]
pub enum Event {
LanguageRegistered,
DiagnosticsUpdated(Arc<Path>),
}
@ -1060,6 +1061,7 @@ impl LocalWorktree {
) -> Option<Arc<LanguageServer>> {
if !self.languages.iter().any(|l| Arc::ptr_eq(l, language)) {
self.languages.push(language.clone());
cx.emit(Event::LanguageRegistered);
}
if let Some(server) = self.language_servers.get(language.name()) {