emacs-diffs
[Top][All Lists]
Advanced

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

feature/eglot2emacs 1d9542cbe8 059/120: Protect against empty firsttrigg


From: João Távora
Subject: feature/eglot2emacs 1d9542cbe8 059/120: Protect against empty firsttriggercharacter strings
Date: Thu, 20 Oct 2022 07:16:53 -0400 (EDT)

branch: feature/eglot2emacs
commit 1d9542cbe8e4249d185518b746437b83de855810
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    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.
    
    GitHub-reference: fix https://github.com/joaotavora/eglot/issues/906
---
 lisp/progmodes/eglot.el | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index ade8a7c711..86e798fabd 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/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

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