@@ -7,6 +7,10 @@ function! lsp#ui#vim#utils#locations_to_loc_list(result) abort
7
7
8
8
let l: locations = type (a: result [' response' ][' result' ]) == type ({}) ? [a: result [' response' ][' result' ]] : a: result [' response' ][' result' ]
9
9
10
+ if empty (l: locations ) " some servers also return null so check to make sure it isn't empty
11
+ return []
12
+ endif
13
+
10
14
if has_key (l: locations [0 ],' targetUri' ) " server returns locationLinks
11
15
let l: use_link = 1
12
16
let l: uri = ' targetUri'
@@ -17,50 +21,48 @@ function! lsp#ui#vim#utils#locations_to_loc_list(result) abort
17
21
let l: range = ' range'
18
22
endif
19
23
20
- if ! empty (l: locations ) " some servers also return null so check to make sure it isn't empty
21
- let l: cache= {}
22
- for l: location in l: locations
23
- if s: is_file_uri (l: location [l: uri ])
24
- let l: path = lsp#utils#uri_to_path (l: location [l: uri ])
25
- let l: line = l: location [l: range ][' start' ][' line' ] + 1
26
- let l: char = l: location [l: range ][' start' ][' character' ]
27
- let l: col = lsp#utils#to_col (l: path , l: line , l: char )
24
+ let l: cache= {}
25
+ for l: location in l: locations
26
+ if s: is_file_uri (l: location [l: uri ])
27
+ let l: path = lsp#utils#uri_to_path (l: location [l: uri ])
28
+ let l: line = l: location [l: range ][' start' ][' line' ] + 1
29
+ let l: char = l: location [l: range ][' start' ][' character' ]
30
+ let l: col = lsp#utils#to_col (l: path , l: line , l: char )
28
31
29
- let l: index = l: line - 1
30
- if has_key (l: cache , l: path )
31
- let l: text = l: cache [l: path ][l: index ]
32
- else
33
- let l: contents = getbufline (l: path , 1 , ' $' )
34
- if ! empty (l: contents )
35
- let l: text = l: contents [l: index ]
36
- else
37
- let l: contents = readfile (l: path )
38
- let l: cache [l: path ] = l: contents
39
- let l: text = l: contents [l: index ]
40
- endif
41
- endif
42
- if l: use_link
43
- let l: viewstart = l: location [' targetRange' ][' start' ][' line' ]
44
- let l: viewend = l: location [' targetRange' ][' end' ][' line' ]
45
- call add (l: list , {
46
- \ ' filename' : l: path ,
47
- \ ' lnum' : l: line ,
48
- \ ' col' : l: col ,
49
- \ ' text' : l: text ,
50
- \ ' viewstart' : l: viewstart ,
51
- \ ' viewend' : l: viewend
52
- \ })
32
+ let l: index = l: line - 1
33
+ if has_key (l: cache , l: path )
34
+ let l: text = l: cache [l: path ][l: index ]
35
+ else
36
+ let l: contents = getbufline (l: path , 1 , ' $' )
37
+ if ! empty (l: contents )
38
+ let l: text = l: contents [l: index ]
53
39
else
54
- call add (l: list , {
55
- \ ' filename' : l: path ,
56
- \ ' lnum' : l: line ,
57
- \ ' col' : l: col ,
58
- \ ' text' : l: text ,
59
- \ })
40
+ let l: contents = readfile (l: path )
41
+ let l: cache [l: path ] = l: contents
42
+ let l: text = l: contents [l: index ]
60
43
endif
61
44
endif
62
- endfor
63
- endif
45
+ if l: use_link
46
+ let l: viewstart = l: location [' targetRange' ][' start' ][' line' ]
47
+ let l: viewend = l: location [' targetRange' ][' end' ][' line' ]
48
+ call add (l: list , {
49
+ \ ' filename' : l: path ,
50
+ \ ' lnum' : l: line ,
51
+ \ ' col' : l: col ,
52
+ \ ' text' : l: text ,
53
+ \ ' viewstart' : l: viewstart ,
54
+ \ ' viewend' : l: viewend
55
+ \ })
56
+ else
57
+ call add (l: list , {
58
+ \ ' filename' : l: path ,
59
+ \ ' lnum' : l: line ,
60
+ \ ' col' : l: col ,
61
+ \ ' text' : l: text ,
62
+ \ })
63
+ endif
64
+ endif
65
+ endfor
64
66
65
67
return l: list
66
68
endfunction
0 commit comments