1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-27 16:51:06 -07:00

Eglot: guard against empty 'textDocument/documentSymbol' response

* lisp/progmodes/eglot.el (eglot-imenu): Protect against missing response.
This commit is contained in:
João Távora 2023-04-17 01:37:19 +01:00
parent 3c8167ec0f
commit 2d24eb69ed

View file

@ -3295,10 +3295,11 @@ Returns a list as described in docstring of `imenu--index-alist'."
`(:textDocument
,(eglot--TextDocumentIdentifier))
:cancel-on-input non-essential))
(head (and res (elt res 0))))
(eglot--dcase head
(((SymbolInformation)) (eglot--imenu-SymbolInformation res))
(((DocumentSymbol)) (eglot--imenu-DocumentSymbol res)))))
(head (and (cl-plusp (length res)) (elt res 0))))
(when head
(eglot--dcase head
(((SymbolInformation)) (eglot--imenu-SymbolInformation res))
(((DocumentSymbol)) (eglot--imenu-DocumentSymbol res))))))
(cl-defun eglot--apply-text-edits (edits &optional version)
"Apply EDITS for current buffer if at VERSION, or if it's nil."