Skip to content

Commit daaa291

Browse files
leungbkkiennq
andauthored
Handle single-location xref results when compiling with `lsp-use-plists' set to t (#2284)
Otherwise, we get a type error. Co-authored-by: Kien Nguyen <[email protected]>
1 parent e96968b commit daaa291

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lsp-mode.el

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4517,11 +4517,15 @@ and the position respectively."
45174517
(lsp:location-link-target-selection-range loc)))
45184518

45194519
(defun lsp--locations-to-xref-items (locations)
4520-
"Return a list of `xref-item' from Location[] or LocationLink[]."
4521-
(setq locations (if (sequencep locations)
4522-
(append locations nil)
4523-
(list locations)))
4524-
4520+
"Return a list of `xref-item' given LOCATIONS, which can be of
4521+
type Location, LocationLink, Location[] or LocationLink[]."
4522+
(setq locations
4523+
(if (and (sequencep locations)
4524+
(let ((fst (lsp-seq-first locations)))
4525+
(or (lsp-location? fst)
4526+
(lsp-location-link? fst))))
4527+
(append locations nil)
4528+
(list locations)))
45254529

45264530
(cl-labels ((get-xrefs-in-file
45274531
(file-locs)

0 commit comments

Comments
 (0)