]> git.eshelyaron.com Git - emacs.git/commitdiff
Eglot: simplify and hopefully fix last change (bug#64784)
authorJoão Távora <joaotavora@gmail.com>
Sat, 22 Jul 2023 09:30:24 +0000 (10:30 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sat, 22 Jul 2023 09:30:24 +0000 (10:30 +0100)
* lisp/progmodes/eglot.el (eglot--post-self-insert-hook): Use
last-command-event.

lisp/progmodes/eglot.el

index 172fd97fdb531e21c01ef5a787a9b8c8876619ed..ae31985a676c9fbc902a9aa713fa75ad7736d80c 100644 (file)
@@ -2447,18 +2447,16 @@ buffer."
 
 (defun eglot--post-self-insert-hook ()
   "Set `eglot--last-inserted-char', maybe call on-type-formatting."
-  (setq eglot--last-inserted-char last-input-event)
-  (let ((ot-provider (eglot--server-capable :documentOnTypeFormattingProvider))
-        ;; transform carriage return into line-feed
-        (adjusted-ie (if (= last-input-event 13) 10 last-input-event)))
+  (setq eglot--last-inserted-char last-command-event)
+  (let ((ot-provider (eglot--server-capable :documentOnTypeFormattingProvider)))
     (when (and ot-provider
                (ignore-errors ; github#906, some LS's send empty strings
-                 (or (eq adjusted-ie
+                 (or (eq eglot--last-inserted-char
                          (seq-first (plist-get ot-provider :firstTriggerCharacter)))
-                     (cl-find adjusted-ie
+                     (cl-find eglot--last-inserted-char
                               (plist-get ot-provider :moreTriggerCharacter)
                               :key #'seq-first))))
-      (eglot-format (point) nil adjusted-ie))))
+      (eglot-format (point) nil eglot--last-inserted-char))))
 
 (defvar eglot--workspace-symbols-cache (make-hash-table :test #'equal)
   "Cache of `workspace/Symbol' results  used by `xref-find-definitions'.")