Skip to content

Commit 9ed883f

Browse files
Publish diagnostics on file open
Diagnostics are sometimes only showing up when typing. This should fix that.
1 parent db6988d commit 9ed883f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,7 @@ impl GlobalState {
348348
}
349349

350350
if self.status == Status::Ready && (state_changed || prev_status == Status::Loading) {
351-
let subscriptions = self
352-
.mem_docs
353-
.keys()
354-
.map(|path| self.vfs.read().0.file_id(&path).unwrap())
355-
.collect::<Vec<_>>();
356-
357-
self.update_file_notifications_on_threadpool(subscriptions);
351+
self.update_file_notifications_on_threadpool();
358352

359353
// Refresh semantic tokens if the client supports it.
360354
if self.config.semantic_tokens_refresh {
@@ -498,6 +492,7 @@ impl GlobalState {
498492
.write()
499493
.0
500494
.set_file_contents(path, Some(params.text_document.text.into_bytes()));
495+
this.update_file_notifications_on_threadpool();
501496
}
502497
Ok(())
503498
})?
@@ -606,7 +601,13 @@ impl GlobalState {
606601
.finish();
607602
Ok(())
608603
}
609-
fn update_file_notifications_on_threadpool(&mut self, subscriptions: Vec<FileId>) {
604+
fn update_file_notifications_on_threadpool(&mut self) {
605+
let subscriptions = self
606+
.mem_docs
607+
.keys()
608+
.map(|path| self.vfs.read().0.file_id(&path).unwrap())
609+
.collect::<Vec<_>>();
610+
610611
log::trace!("updating notifications for {:?}", subscriptions);
611612
if self.config.publish_diagnostics {
612613
let snapshot = self.snapshot();

0 commit comments

Comments
 (0)