From: João Távora Date: Tue, 26 Dec 2023 13:47:29 +0000 (-0600) Subject: Eglot: Make 'try-completion' less broken X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d495cbf0d0103b93e7b3653224e7e260790f98bb;p=emacs.git Eglot: Make 'try-completion' less broken The 'try-completion' completion operation, used mostly in vanilla 'completion-at-point' invoked with C-M-i is close to impossible to get right in LSP because of the arbitrary edits handled in ':exit-function'. When this operation is invoked on the table, returning the pattern argument unchanged somehow (TM) makes a sole completion show the *Completions* buffer, where selecting it will recover context necessary for `:exit-function' and call that function. It doesn't break any other cases I know, and that's good enough for now. https://github.com/joaotavora/eglot/issues/1339 * lisp/progmodes/eglot.el (eglot-completion-at-point): Return pattern when 'try-completion' is invoked. (cherry picked from commit 4dcbf61c1518dc53061707aeff8887517e050003) --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index d777e488c43..a97c9e2a3e0 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3113,8 +3113,8 @@ for which LSP on-type-formatting should be requested." ((eq action 'lambda) ; test-completion (test-completion pattern (funcall proxies))) ((eq (car-safe action) 'boundaries) nil) ; boundaries - ((null action) ; try-completion - (try-completion pattern (funcall proxies))) + ((null action) ; try-completion (github#1339) + pattern) ((eq action t) ; all-completions (let ((comps (funcall proxies))) (dolist (c comps) (eglot--dumb-flex pattern c t)) @@ -3215,7 +3215,8 @@ for which LSP on-type-formatting should be requested." ;; was obtained from server. If a `proxy' ;; "bar" was obtained from a buffer with ;; "foo.b", the LSP edit applies to that - ;; state, _not_ the current "foo.bar". + ;; state, _not_ the current "foo.bar" + ;; (github#1339) (delete-region orig-pos (point)) (insert (substring bounds-string (- orig-pos (car bounds)))) (eglot--dbind ((TextEdit) range newText) textEdit