emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 2d24eb69ed5: Eglot: guard against empty 'textDocument/documentSym


From: João Távora
Subject: master 2d24eb69ed5: Eglot: guard against empty 'textDocument/documentSymbol' response
Date: Sun, 16 Apr 2023 20:36:34 -0400 (EDT)

branch: master
commit 2d24eb69ed56b00f400066f4dfcf549d69036ce6
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]