From 2d24eb69ed56b00f400066f4dfcf549d69036ce6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 17 Apr 2023 01:37:19 +0100 Subject: [PATCH] Eglot: guard against empty 'textDocument/documentSymbol' response * lisp/progmodes/eglot.el (eglot-imenu): Protect against missing response. --- lisp/progmodes/eglot.el | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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." -- 2.39.5