]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't choke on single-location reply to td/definition
authorJoão Távora <joaotavora@gmail.com>
Wed, 16 Oct 2019 18:25:51 +0000 (19:25 +0100)
committerJoão Távora <joaotavora@gmail.com>
Wed, 16 Oct 2019 18:25:51 +0000 (19:25 +0100)
* eglot.el (eglot--lsp-xrefs-for-method): Accept non-vector
Location.

GitHub-reference: fix https://github.com/joaotavora/eglot/issues/321

lisp/progmodes/eglot.el

index bb5d5f816902ea8233a9ff9efe1f741bb0d2fd4b..aa64fe6a2a9d950af1462c7cdb8cc60c1039eaae 100644 (file)
@@ -1791,14 +1791,15 @@ Try to visit the target file for a richer summary line."
                         (cadr (split-string (symbol-name method)
                                             "/"))))))
     (eglot--error "Sorry, this server doesn't do %s" method))
-  (eglot--collecting-xrefs (collect)
-    (mapc
-     (eglot--lambda ((Location) uri range)
-       (collect (eglot--xref-make (symbol-at-point) uri range)))
-     (jsonrpc-request
-      (eglot--current-server-or-lose) method (append
-                                              (eglot--TextDocumentPositionParams)
-                                              extra-params)))))
+  (let ((response
+         (jsonrpc-request
+          (eglot--current-server-or-lose)
+          method (append (eglot--TextDocumentPositionParams) extra-params))))
+    (eglot--collecting-xrefs (collect)
+      (mapc
+       (eglot--lambda ((Location) uri range)
+         (collect (eglot--xref-make (symbol-at-point) uri range)))
+       (if (vectorp response) response (list response))))))
 
 (cl-defun eglot--lsp-xref-helper (method &key extra-params capability )
   "Helper for `eglot-find-declaration' & friends."