From: João Távora Date: Wed, 16 Oct 2019 18:25:51 +0000 (+0100) Subject: Don't choke on single-location reply to td/definition X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~297 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5d1c5c64b17a127daa0e69a14bce1e68362f36ef;p=emacs.git Don't choke on single-location reply to td/definition * eglot.el (eglot--lsp-xrefs-for-method): Accept non-vector Location. GitHub-reference: fix https://github.com/joaotavora/eglot/issues/321 --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index bb5d5f81690..aa64fe6a2a9 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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."