GNU bug report logs - #72705
31.0.50; eglot--dumb-tryc Filters out too much

Previous Next

Package: emacs;

Reported by: Dmitry Gutov <dmitry <at> gutov.dev>

Date: Mon, 19 Aug 2024 01:53:02 UTC

Severity: normal

Found in version 31.0.50

Done: Dmitry Gutov <dmitry <at> gutov.dev>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: 72705 <at> debbugs.gnu.org
Cc: joaotavora <at> gmail.com
Subject: bug#72705: 31.0.50; eglot--dumb-tryc Filters out too much
Date: Mon, 19 Aug 2024 04:51:15 +0300
[Message part 1 (text/plain, inline)]
X-Debbugs-Cc: joaotavora <at> gmail.com

1. Have a project with just one file, test.go (attached).
2. Visit it, enable go-ts-mode, call 'M-x eglot'.
3. Move point right after "math.As", press C-M-i.
4. Code will get completed to "math.Asin"

This is a problem because "math.As" has more completions (one can look
at them by pressing TAB after "math.A") - such as "Acos", "Acosh" and
"Abs" - in other words, "fuzzy" matches.

Expected behavior:

1. When input is "math.As" - keep the string as-is.
2. When input is "math.Asi" - complete to "math.Asin".

This problem seems older than 65ea742ed5ec (the change that introduced
eglot--dumb-tryc itself, bug#68699), but it doesn't reproduce with Eglot
from Emacs 29. Branches emacs-30 and master are affected.

There is also another issue there: when there are no completions at all,
this style still has completion-try-completion return a non-nil value
(the last line of the implementation).

Both of these issues is something I came across when working on closer
'try-completion' integration for company-mode
(https://github.com/company-mode/company-mode/pull/1488) and testing out
the new code with Eglot.

Not sure what's the best fix, but the patch below seems to address both
problems in my limited testing. WDYT?

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 353877f60c2..e8823a9d2f0 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -3142,8 +3142,14 @@ eglot--dumb-allc
 (defun eglot--dumb-tryc (pat table pred point)
   (let ((probe (funcall table pat pred nil)))
     (cond ((eq probe t) t)
-          (probe (cons probe (length probe)))
-          (t (cons pat point)))))
+          ((and probe
+                (cl-every
+                 (lambda (s) (string-prefix-p probe s 
completion-ignore-case))
+                 (funcall table pat pred t)))
+           (cons probe (length probe)))
+          (t
+           (and (funcall table pat pred t)
+                (cons pat point))))))
  (add-to-list 'completion-category-defaults '(eglot-capf (styles 
eglot--dumb-flex)))
 (add-to-list 'completion-styles-alist '(eglot--dumb-flex 
eglot--dumb-tryc eglot--dumb-allc))
[test.go (text/x-go, attachment)]

This bug report was last modified 267 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.