From 1d9542cbe8e4249d185518b746437b83de855810 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Thu, 31 Mar 2022 14:21:29 +0100 Subject: [PATCH] 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 ade8a7c7118..86e798fabdd 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 () -- 2.39.2