aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/rust-analyzer/src/handlers.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 4f6f250d6..e81fc9926 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -1135,20 +1135,13 @@ pub(crate) fn handle_document_highlight(
1135 None 1135 None
1136 }; 1136 };
1137 1137
1138 let res = refs 1138 let file_refs = refs.references.get(&position.file_id).map_or(&[][..], Vec::as_slice);
1139 .references 1139 let mut res = Vec::with_capacity(file_refs.len() + 1);
1140 .get(&position.file_id) 1140 res.extend(decl);
1141 .map(|file_refs| { 1141 res.extend(file_refs.iter().map(|&(range, access)| DocumentHighlight {
1142 file_refs 1142 range: to_proto::range(&line_index, range),
1143 .into_iter() 1143 kind: access.map(to_proto::document_highlight_kind),
1144 .map(|&(range, access)| DocumentHighlight { 1144 }));
1145 range: to_proto::range(&line_index, range),
1146 kind: access.map(to_proto::document_highlight_kind),
1147 })
1148 .chain(decl)
1149 .collect()
1150 })
1151 .unwrap_or_default();
1152 Ok(Some(res)) 1145 Ok(Some(res))
1153} 1146}
1154 1147