Skip to content

Commit a1f0801

Browse files
committed
Fix unused definitions not being document highlit
1 parent d54e115 commit a1f0801

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

crates/rust-analyzer/src/handlers.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,20 +1135,13 @@ pub(crate) fn handle_document_highlight(
11351135
None
11361136
};
11371137

1138-
let res = refs
1139-
.references
1140-
.get(&position.file_id)
1141-
.map(|file_refs| {
1142-
file_refs
1143-
.into_iter()
1144-
.map(|&(range, access)| DocumentHighlight {
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();
1138+
let file_refs = refs.references.get(&position.file_id).map_or(&[][..], Vec::as_slice);
1139+
let mut res = Vec::with_capacity(file_refs.len() + 1);
1140+
res.extend(decl);
1141+
res.extend(file_refs.iter().map(|&(range, access)| DocumentHighlight {
1142+
range: to_proto::range(&line_index, range),
1143+
kind: access.map(to_proto::document_highlight_kind),
1144+
}));
11521145
Ok(Some(res))
11531146
}
11541147

0 commit comments

Comments
 (0)