@@ -192,39 +192,21 @@ fn handle_goto_definition(
192192 let line_index = LineIndex :: new ( content) ;
193193 let offset = lsp_utils:: offset ( & line_index, position) . unwrap ( ) ;
194194
195- let ranges = goto_definition ( file, offset) ;
196-
197- let result = if ranges. is_empty ( ) {
198- GotoDefinitionResponse :: Array ( vec ! [ ] )
199- } else if ranges. len ( ) == 1 {
200- // TODO: can we just always use the array response?
201- let target_range = ranges[ 0 ] ;
202- debug_assert ! (
203- !target_range. contains( offset) ,
204- "Our target destination range must not include the source range otherwise go to def won't work in vscode."
205- ) ;
206- GotoDefinitionResponse :: Scalar ( Location {
207- uri : uri. clone ( ) ,
208- range : lsp_utils:: range ( & line_index, target_range) ,
195+ let ranges = goto_definition ( file, offset)
196+ . into_iter ( )
197+ . map ( |target_range| {
198+ debug_assert ! (
199+ !target_range. contains( offset) ,
200+ "Our target destination range must not include the source range otherwise go to def won't work in vscode."
201+ ) ;
202+ Location {
203+ uri : uri. clone ( ) ,
204+ range : lsp_utils:: range ( & line_index, target_range) ,
205+ }
209206 } )
210- } else {
211- GotoDefinitionResponse :: Array (
212- ranges
213- . into_iter ( )
214- . map ( |target_range| {
215- debug_assert ! (
216- !target_range. contains( offset) ,
217- "Our target destination range must not include the source range otherwise go to def won't work in vscode."
218- ) ;
219- Location {
220- uri : uri. clone ( ) ,
221- range : lsp_utils:: range ( & line_index, target_range) ,
222- }
223- } )
224- . collect ( ) ,
225- )
226- } ;
207+ . collect ( ) ;
227208
209+ let result = GotoDefinitionResponse :: Array ( ranges) ;
228210 let resp = Response {
229211 id : req. id ,
230212 result : Some ( serde_json:: to_value ( & result) . unwrap ( ) ) ,
0 commit comments