From: João Távora Date: Mon, 17 Apr 2023 00:37:19 +0000 (+0100) Subject: Eglot: guard against empty 'textDocument/documentSymbol' response X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2d24eb69ed56b00f400066f4dfcf549d69036ce6;p=emacs.git Eglot: guard against empty 'textDocument/documentSymbol' response * lisp/progmodes/eglot.el (eglot-imenu): Protect against missing response. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 24f2fda5ae5..7ad33fa3786 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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."