@@ -232,45 +232,47 @@ findEnclosingFunc:
232
232
}
233
233
}
234
234
235
- // Scan fields, either adding highlights according to the highlightIndexes
236
- // computed above, or accounting for the cursor position within the result
237
- // list.
238
- // (We do both at once to avoid repeating the cumbersome field traversal.)
239
- i := 0
240
- findField:
241
- for _ , field := range funcType .Results .List {
242
- for j , name := range field .Names {
243
- if inNode (name ) || highlightIndexes [i + j ] {
244
- result [posRange {name .Pos (), name .End ()}] = unit {}
245
- highlightIndexes [i + j ] = true
246
- break findField // found/highlighted the specific name
247
- }
248
- }
249
- // If the cursor is in a field but not in a name (e.g. in the space, or
250
- // the type), highlight the whole field.
251
- //
252
- // Note that this may not be ideal if we're at e.g.
253
- //
254
- // (x,‸y int, z int8)
255
- //
256
- // ...where it would make more sense to highlight only y. But we don't
257
- // reach this function if not in a func, return, ident, or basiclit.
258
- if inNode (field ) || highlightIndexes [i ] {
259
- result [posRange {field .Pos (), field .End ()}] = unit {}
260
- highlightIndexes [i ] = true
261
- if inNode (field ) {
262
- for j := range field .Names {
235
+ if funcType .Results != nil {
236
+ // Scan fields, either adding highlights according to the highlightIndexes
237
+ // computed above, or accounting for the cursor position within the result
238
+ // list.
239
+ // (We do both at once to avoid repeating the cumbersome field traversal.)
240
+ i := 0
241
+ findField:
242
+ for _ , field := range funcType .Results .List {
243
+ for j , name := range field .Names {
244
+ if inNode (name ) || highlightIndexes [i + j ] {
245
+ result [posRange {name .Pos (), name .End ()}] = unit {}
263
246
highlightIndexes [i + j ] = true
247
+ break findField // found/highlighted the specific name
264
248
}
265
249
}
266
- break findField // found/highlighted the field
267
- }
250
+ // If the cursor is in a field but not in a name (e.g. in the space, or
251
+ // the type), highlight the whole field.
252
+ //
253
+ // Note that this may not be ideal if we're at e.g.
254
+ //
255
+ // (x,‸y int, z int8)
256
+ //
257
+ // ...where it would make more sense to highlight only y. But we don't
258
+ // reach this function if not in a func, return, ident, or basiclit.
259
+ if inNode (field ) || highlightIndexes [i ] {
260
+ result [posRange {field .Pos (), field .End ()}] = unit {}
261
+ highlightIndexes [i ] = true
262
+ if inNode (field ) {
263
+ for j := range field .Names {
264
+ highlightIndexes [i + j ] = true
265
+ }
266
+ }
267
+ break findField // found/highlighted the field
268
+ }
268
269
269
- n := len (field .Names )
270
- if n == 0 {
271
- n = 1
270
+ n := len (field .Names )
271
+ if n == 0 {
272
+ n = 1
273
+ }
274
+ i += n
272
275
}
273
- i += n
274
276
}
275
277
}
276
278
}
0 commit comments