]> git.eshelyaron.com Git - emacs.git/commitdiff
Protect against empty firsttriggercharacter strings
authorJoão Távora <joaotavora@gmail.com>
Thu, 31 Mar 2022 13:21:29 +0000 (14:21 +0100)
committerJoão Távora <joaotavora@gmail.com>
Thu, 31 Mar 2022 13:22:05 +0000 (14:22 +0100)
Which some LS's like gopls like to send.

* eglot.el (eglot--post-self-insert-hook): Beware of empty strings.

GitHub-reference: fix https://github.com/joaotavora/eglot/issues/906

lisp/progmodes/eglot.el

index ade8a7c7118a95c057b0ba73699b56781a59f9b9..86e798fabdda4634aa2010a906dc5cf25b67cdd5 100644 (file)
@@ -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 ()