diff options
author | Matt Jibson <[email protected]> | 2020-11-23 23:35:34 +0000 |
---|---|---|
committer | Matt Jibson <[email protected]> | 2020-11-23 23:35:34 +0000 |
commit | 117c793e80f3b8a41b045cfa5d320ef157f2446c (patch) | |
tree | abc50f56d6e439c3ed4a4d5769790e31992f0e4f | |
parent | 48bb4bf22895edd3658658f088499b0dd60df371 (diff) |
Don't assume DidChangeTextDocument paths exist
Fixes #5933
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 6ea08adce..b34ff092d 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -503,7 +503,13 @@ impl GlobalState { | |||
503 | })? | 503 | })? |
504 | .on::<lsp_types::notification::DidChangeTextDocument>(|this, params| { | 504 | .on::<lsp_types::notification::DidChangeTextDocument>(|this, params| { |
505 | if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) { | 505 | if let Ok(path) = from_proto::vfs_path(¶ms.text_document.uri) { |
506 | let doc = this.mem_docs.get_mut(&path).unwrap(); | 506 | let doc = match this.mem_docs.get_mut(&path) { |
507 | Some(doc) => doc, | ||
508 | None => { | ||
509 | log::error!("expected DidChangeTextDocument: {}", path); | ||
510 | return Ok(()); | ||
511 | } | ||
512 | }; | ||
507 | let vfs = &mut this.vfs.write().0; | 513 | let vfs = &mut this.vfs.write().0; |
508 | let file_id = vfs.file_id(&path).unwrap(); | 514 | let file_id = vfs.file_id(&path).unwrap(); |
509 | let mut text = String::from_utf8(vfs.file_contents(file_id).to_vec()).unwrap(); | 515 | let mut text = String::from_utf8(vfs.file_contents(file_id).to_vec()).unwrap(); |