Skip to content

Commit 2ff78cd

Browse files
Merge #6613
6613: Don't assume DidChangeTextDocument paths exist r=SomeoneToIgnore a=mjibson Fixes #5933 Co-authored-by: Matt Jibson <[email protected]>
2 parents 036ea63 + 117c793 commit 2ff78cd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,13 @@ impl GlobalState {
503503
})?
504504
.on::<lsp_types::notification::DidChangeTextDocument>(|this, params| {
505505
if let Ok(path) = from_proto::vfs_path(&params.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+
};
507513
let vfs = &mut this.vfs.write().0;
508514
let file_id = vfs.file_id(&path).unwrap();
509515
let mut text = String::from_utf8(vfs.file_contents(file_id).to_vec()).unwrap();

0 commit comments

Comments
 (0)