GNU bug report logs -
#72705
31.0.50; eglot--dumb-tryc Filters out too much
Previous Next
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
[Message part 1 (text/plain, inline)]
Your message dated Mon, 26 Aug 2024 02:40:34 +0300
with message-id <fe38cc22-b4ff-461a-883d-e5ca127d3a9d <at> gutov.dev>
and subject line Re: bug#72705: 31.0.50; eglot--dumb-tryc Filters out too much
has caused the debbugs.gnu.org bug report #72705,
regarding 31.0.50; eglot--dumb-tryc Filters out too much
to be marked as done.
(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)
--
72705: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=72705
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
[Message part 3 (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)]
[Message part 5 (message/rfc822, inline)]
On 25/08/2024 12:53, João Távora wrote:
>>>> Okay, I am seeing a difference too: C-M-i does eat the suffix in the
>>>> Rust example (the "1234"). But completion with Company does not :-/
>>> I can't even get Company to appear in those situations.
>> You might have an older version installed?
> Maybe.
Okay, I've tracked this one down to Company adhering to what completion
style is being used.
When no completions match the suffix, completion-all-completions falls
back to c-style 'emacs22' (if it's in completion-styles anyway). And
when that style is used, we don't replace the suffix. There is a report
for vanilla completion in bug#70968.
That seems to cover all related issues I've found so far.
Thanks, and closing.
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.