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 2c4c339cb..b5b2ffe50 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -1134,20 +1134,13 @@ pub(crate) fn handle_document_highlight(
1134 None 1134 None
1135 }; 1135 };
1136 1136
1137 let res = refs 1137 let file_refs = refs.references.get(&position.file_id).map_or(&[][..], Vec::as_slice);
1138 .references 1138 let mut res = Vec::with_capacity(file_refs.len() + 1);
1139 .get(&position.file_id) 1139 res.extend(decl);
1140 .map(|file_refs| { 1140 res.extend(file_refs.iter().map(|&(range, access)| DocumentHighlight {
1141 file_refs 1141 range: to_proto::range(&line_index, range),
1142 .into_iter() 1142 kind: access.map(to_proto::document_highlight_kind),
1143 .map(|&(range, access)| DocumentHighlight { 1143 }));
1144 range: to_proto::range(&line_index, range),
1145 kind: access.map(to_proto::document_highlight_kind),
1146 })
1147 .chain(decl)
1148 .collect()
1149 })
1150 .unwrap_or_default();
1151 Ok(Some(res)) 1144 Ok(Some(res))
1152} 1145}
1153 1146