File tree Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -1135,20 +1135,13 @@ pub(crate) fn handle_document_highlight(
1135
1135
None
1136
1136
} ;
1137
1137
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
+ } ) ) ;
1152
1145
Ok ( Some ( res) )
1153
1146
}
1154
1147
You can’t perform that action at this time.
0 commit comments