branch: externals/eglot
commit fd9a5646d1b49ef5968713005d83131dd75a52ad
Author: João Távora <[email protected]>
Commit: João Távora <[email protected]>

    Fix #906: Protect against empty firstTriggerCharacter strings
    
    Which some LS's like gopls like to send.
    
    * eglot.el (eglot--post-self-insert-hook): Beware of empty strings.
---
 eglot.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/eglot.el b/eglot.el
index ade8a7c711..86e798fabd 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1993,11 +1993,12 @@ THINGS are either registrations or unregisterations 
(sic)."
   (setq eglot--last-inserted-char last-input-event)
   (let ((ot-provider (eglot--server-capable 
:documentOnTypeFormattingProvider)))
     (when (and ot-provider
-               (or (eq last-input-event
-                       (elt (plist-get ot-provider :firstTriggerCharacter) 0))
-                   (cl-find last-input-event
-                            (plist-get ot-provider :moreTriggerCharacter)
-                            :key #'seq-first)))
+               (ignore-errors ; github#906, some LS's send empty strings
+                 (or (eq last-input-event
+                         (seq-first (plist-get ot-provider 
:firstTriggerCharacter)))
+                     (cl-find last-input-event
+                              (plist-get ot-provider :moreTriggerCharacter)
+                              :key #'seq-first))))
       (eglot-format (point) nil last-input-event))))
 
 (defun eglot--pre-command-hook ()

Reply via email to