6613: Don't assume DidChangeTextDocument paths exist r=SomeoneToIgnore a=mjibson

Fixes #5933

Co-authored-by: Matt Jibson <matt.jibson@gmail.com>
This commit is contained in:
bors[bot] 2020-11-24 00:41:08 +00:00 committed by GitHub
commit 2ff78cde31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -503,7 +503,13 @@ impl GlobalState {
})?
.on::<lsp_types::notification::DidChangeTextDocument>(|this, params| {
if let Ok(path) = from_proto::vfs_path(&params.text_document.uri) {
let doc = this.mem_docs.get_mut(&path).unwrap();
let doc = match this.mem_docs.get_mut(&path) {
Some(doc) => doc,
None => {
log::error!("expected DidChangeTextDocument: {}", path);
return Ok(());
}
};
let vfs = &mut this.vfs.write().0;
let file_id = vfs.file_id(&path).unwrap();
let mut text = String::from_utf8(vfs.file_contents(file_id).to_vec()).unwrap();