aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop.rs
diff options
context:
space:
mode:
authorEmil Lauridsen <[email protected]>2020-02-07 11:30:29 +0000
committerEmil Lauridsen <[email protected]>2020-02-07 11:30:29 +0000
commit5db7c8642beb1cd4c09359c3f3266d67557a30f9 (patch)
treecbb5b49a71415dc4326fcfae43c57266881d1120 /crates/ra_lsp_server/src/main_loop.rs
parent5aba5a756a19a54d5c4edd51d8055db36182688b (diff)
Don't crash when recieving unkown file for cargo diagnostic.
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop.rs')
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 12961ba37..fcae37bb7 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -635,12 +635,16 @@ fn on_check_task(
635 635
636 CheckTask::AddDiagnostic { url, diagnostic, fixes } => { 636 CheckTask::AddDiagnostic { url, diagnostic, fixes } => {
637 let path = url.to_file_path().map_err(|()| format!("invalid uri: {}", url))?; 637 let path = url.to_file_path().map_err(|()| format!("invalid uri: {}", url))?;
638 let file_id = world_state 638 let file_id = match world_state.vfs.read().path2file(&path) {
639 .vfs 639 Some(file) => FileId(file.0),
640 .read() 640 None => {
641 .path2file(&path) 641 log::error!(
642 .map(|it| FileId(it.0)) 642 "File with cargo diagnostic not found in VFS: {}",
643 .ok_or_else(|| format!("unknown file: {}", path.to_string_lossy()))?; 643 path.to_string_lossy()
644 );
645 return Ok(());
646 }
647 };
644 648
645 task_sender 649 task_sender
646 .send(Task::Diagnostic(DiagnosticTask::AddCheck(file_id, diagnostic, fixes)))?; 650 .send(Task::Diagnostic(DiagnosticTask::AddCheck(file_id, diagnostic, fixes)))?;