emacs-diffs
[Top][All Lists]
Advanced

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

master b71ddaf6d3a: Eglot: ensure quick typing doesn't undermine complet


From: João Távora
Subject: master b71ddaf6d3a: Eglot: ensure quick typing doesn't undermine completion exit
Date: Fri, 20 Dec 2024 18:27:50 -0500 (EST)

branch: master
commit b71ddaf6d3ac39487302fbc27614b9de28bf6cef
Author: João Távora <joaotavora@gmail.com>
Commit: João Távora <joaotavora@gmail.com>

    Eglot: ensure quick typing doesn't undermine completion exit
    
    Some completion resolution requests in
    eglot-completion-at-point, specifically those that might be
    triggered from the :exit function, can't be cancellable, else
    the completion edit or snippet will never be obtained and the
    user is left with the nonsensical completion label in the
    buffer.
    
    Github-reference: https://github.com/joaotavora/eglot/issues/1474
---
 lisp/progmodes/eglot.el | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index e5c27de81fc..816a1e67eca 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3228,14 +3228,15 @@ for which LSP on-type-formatting should be requested."
             ;; Maybe completion/resolve JSON object `lsp-comp' into
             ;; another JSON object, if at all possible.  Otherwise,
             ;; just return lsp-comp.
-            (lambda (lsp-comp)
+            (lambda (lsp-comp &optional dont-cancel-on-input)
               (or (gethash lsp-comp resolved)
                   (setf (gethash lsp-comp resolved)
                         (if (and (eglot-server-capable :completionProvider
                                                         :resolveProvider)
                                  (plist-get lsp-comp :data))
                             (eglot--request server :completionItem/resolve
-                                            lsp-comp :cancel-on-input t
+                                            lsp-comp :cancel-on-input
+                                            (not dont-cancel-on-input)
                                             :immediate t)
                           lsp-comp))))))
       (when (and (consp eglot--capf-session)
@@ -3350,7 +3351,12 @@ for which LSP on-type-formatting should be requested."
                       ;; A lookup should fix that (github#148)
                       (get-text-property
                        0 'eglot--lsp-item
-                       (cl-find proxy (funcall proxies) :test #'string=))))
+                       (cl-find proxy (funcall proxies) :test #'string=)))
+                  ;; Be sure to pass non-nil here since we don't want
+                  ;; any quick typing after the soon-to-be-undone
+                  ;; insertion to potentially cancel an essential
+                  ;; resolution request (github#1474).
+                  'dont-cancel-on-input)
                (let ((snippet-fn (and (eql insertTextFormat 2)
                                       (eglot--snippet-expansion-fn))))
                  (cond (textEdit



reply via email to

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