Publish diagnostics on file open

Diagnostics are sometimes only showing up when typing.
This should fix that.
This commit is contained in:
Jonas Schievink 2020-11-26 13:33:47 +01:00
parent db6988d4e7
commit 9ed883f373

View file

@ -348,13 +348,7 @@ impl GlobalState {
} }
if self.status == Status::Ready && (state_changed || prev_status == Status::Loading) { if self.status == Status::Ready && (state_changed || prev_status == Status::Loading) {
let subscriptions = self self.update_file_notifications_on_threadpool();
.mem_docs
.keys()
.map(|path| self.vfs.read().0.file_id(&path).unwrap())
.collect::<Vec<_>>();
self.update_file_notifications_on_threadpool(subscriptions);
// Refresh semantic tokens if the client supports it. // Refresh semantic tokens if the client supports it.
if self.config.semantic_tokens_refresh { if self.config.semantic_tokens_refresh {
@ -498,6 +492,7 @@ impl GlobalState {
.write() .write()
.0 .0
.set_file_contents(path, Some(params.text_document.text.into_bytes())); .set_file_contents(path, Some(params.text_document.text.into_bytes()));
this.update_file_notifications_on_threadpool();
} }
Ok(()) Ok(())
})? })?
@ -606,7 +601,13 @@ impl GlobalState {
.finish(); .finish();
Ok(()) Ok(())
} }
fn update_file_notifications_on_threadpool(&mut self, subscriptions: Vec<FileId>) { fn update_file_notifications_on_threadpool(&mut self) {
let subscriptions = self
.mem_docs
.keys()
.map(|path| self.vfs.read().0.file_id(&path).unwrap())
.collect::<Vec<_>>();
log::trace!("updating notifications for {:?}", subscriptions); log::trace!("updating notifications for {:?}", subscriptions);
if self.config.publish_diagnostics { if self.config.publish_diagnostics {
let snapshot = self.snapshot(); let snapshot = self.snapshot();