diff options
| author | João Távora | 2024-12-20 23:11:30 +0000 |
|---|---|---|
| committer | João Távora | 2024-12-20 23:11:47 +0000 |
| commit | b71ddaf6d3ac39487302fbc27614b9de28bf6cef (patch) | |
| tree | 383880881b63ae1e0dabc52f8e6f90685203184f | |
| parent | 8aad208e002a8c7512df77de7a16b67303e964ec (diff) | |
| download | emacs-b71ddaf6d3ac39487302fbc27614b9de28bf6cef.tar.gz emacs-b71ddaf6d3ac39487302fbc27614b9de28bf6cef.zip | |
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
| -rw-r--r-- | lisp/progmodes/eglot.el | 12 |
1 files 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." | |||
| 3228 | ;; Maybe completion/resolve JSON object `lsp-comp' into | 3228 | ;; Maybe completion/resolve JSON object `lsp-comp' into |
| 3229 | ;; another JSON object, if at all possible. Otherwise, | 3229 | ;; another JSON object, if at all possible. Otherwise, |
| 3230 | ;; just return lsp-comp. | 3230 | ;; just return lsp-comp. |
| 3231 | (lambda (lsp-comp) | 3231 | (lambda (lsp-comp &optional dont-cancel-on-input) |
| 3232 | (or (gethash lsp-comp resolved) | 3232 | (or (gethash lsp-comp resolved) |
| 3233 | (setf (gethash lsp-comp resolved) | 3233 | (setf (gethash lsp-comp resolved) |
| 3234 | (if (and (eglot-server-capable :completionProvider | 3234 | (if (and (eglot-server-capable :completionProvider |
| 3235 | :resolveProvider) | 3235 | :resolveProvider) |
| 3236 | (plist-get lsp-comp :data)) | 3236 | (plist-get lsp-comp :data)) |
| 3237 | (eglot--request server :completionItem/resolve | 3237 | (eglot--request server :completionItem/resolve |
| 3238 | lsp-comp :cancel-on-input t | 3238 | lsp-comp :cancel-on-input |
| 3239 | (not dont-cancel-on-input) | ||
| 3239 | :immediate t) | 3240 | :immediate t) |
| 3240 | lsp-comp)))))) | 3241 | lsp-comp)))))) |
| 3241 | (when (and (consp eglot--capf-session) | 3242 | (when (and (consp eglot--capf-session) |
| @@ -3350,7 +3351,12 @@ for which LSP on-type-formatting should be requested." | |||
| 3350 | ;; A lookup should fix that (github#148) | 3351 | ;; A lookup should fix that (github#148) |
| 3351 | (get-text-property | 3352 | (get-text-property |
| 3352 | 0 'eglot--lsp-item | 3353 | 0 'eglot--lsp-item |
| 3353 | (cl-find proxy (funcall proxies) :test #'string=)))) | 3354 | (cl-find proxy (funcall proxies) :test #'string=))) |
| 3355 | ;; Be sure to pass non-nil here since we don't want | ||
| 3356 | ;; any quick typing after the soon-to-be-undone | ||
| 3357 | ;; insertion to potentially cancel an essential | ||
| 3358 | ;; resolution request (github#1474). | ||
| 3359 | 'dont-cancel-on-input) | ||
| 3354 | (let ((snippet-fn (and (eql insertTextFormat 2) | 3360 | (let ((snippet-fn (and (eql insertTextFormat 2) |
| 3355 | (eglot--snippet-expansion-fn)))) | 3361 | (eglot--snippet-expansion-fn)))) |
| 3356 | (cond (textEdit | 3362 | (cond (textEdit |