7941: Fix unused definitions not being document highlit r=Veykril a=Veykril

Fixes #7939

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-03-09 14:54:24 +00:00 committed by GitHub
commit 472641fc5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1134,20 +1134,13 @@ pub(crate) fn handle_document_highlight(
None
};
let res = refs
.references
.get(&position.file_id)
.map(|file_refs| {
file_refs
.into_iter()
.map(|&(range, access)| DocumentHighlight {
range: to_proto::range(&line_index, range),
kind: access.map(to_proto::document_highlight_kind),
})
.chain(decl)
.collect()
})
.unwrap_or_default();
let file_refs = refs.references.get(&position.file_id).map_or(&[][..], Vec::as_slice);
let mut res = Vec::with_capacity(file_refs.len() + 1);
res.extend(decl);
res.extend(file_refs.iter().map(|&(range, access)| DocumentHighlight {
range: to_proto::range(&line_index, range),
kind: access.map(to_proto::document_highlight_kind),
}));
Ok(Some(res))
}