aboutsummaryrefslogtreecommitdiff
path: root/crates/rust-analyzer/src/main_loop.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-12-09 16:29:34 +0000
committerJonas Schievink <[email protected]>2020-12-09 16:30:46 +0000
commit6857989f6f5c399857cddd54598eb2c8cb427e26 (patch)
tree7e812577ff0116ae303b1bb2b710ffd8e19cc352 /crates/rust-analyzer/src/main_loop.rs
parent42be522c80cf0cc2d49b60f3c1d66afdc51fcbbb (diff)
Fix "no value set for FileTextQuery(FileId(..))"
Diffstat (limited to 'crates/rust-analyzer/src/main_loop.rs')
-rw-r--r--crates/rust-analyzer/src/main_loop.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 95be2ebd3..d7f8374af 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -255,7 +255,7 @@ impl GlobalState {
255 for (path, contents) in files { 255 for (path, contents) in files {
256 let path = VfsPath::from(path); 256 let path = VfsPath::from(path);
257 if !self.mem_docs.contains_key(&path) { 257 if !self.mem_docs.contains_key(&path) {
258 vfs.set_file_contents(path, contents) 258 vfs.set_file_contents(path, contents);
259 } 259 }
260 } 260 }
261 } 261 }
@@ -503,11 +503,21 @@ impl GlobalState {
503 { 503 {
504 log::error!("duplicate DidOpenTextDocument: {}", path) 504 log::error!("duplicate DidOpenTextDocument: {}", path)
505 } 505 }
506 this.vfs 506 let changed = this
507 .vfs
507 .write() 508 .write()
508 .0 509 .0
509 .set_file_contents(path, Some(params.text_document.text.into_bytes())); 510 .set_file_contents(path, Some(params.text_document.text.into_bytes()));
510 this.maybe_update_diagnostics(); 511
512 // If the VFS contents are unchanged, update diagnostics, since `handle_event`
513 // won't see any changes. This avoids missing diagnostics when opening a file.
514 //
515 // If the file *was* changed, `handle_event` will already recompute and send
516 // diagnostics. We can't do it here, since the *current* file contents might be
517 // unset in salsa, since the VFS change hasn't been applied to the database yet.
518 if !changed {
519 this.maybe_update_diagnostics();
520 }
511 } 521 }
512 Ok(()) 522 Ok(())
513 })? 523 })?