unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#72705: 31.0.50; eglot--dumb-tryc Filters out too much
@ 2024-08-19  1:51 Dmitry Gutov
  2024-08-19  9:22 ` João Távora
  0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Gutov @ 2024-08-19  1:51 UTC (permalink / raw)
  To: 72705; +Cc: joaotavora

[-- Attachment #1: Type: text/plain, Size: 2169 bytes --]

X-Debbugs-Cc: joaotavora@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))

[-- Attachment #2: test.go --]
[-- Type: text/x-go, Size: 54 bytes --]

package test

import "math"

func main() {
	math.As
}

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-08-25 23:40 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-19  1:51 bug#72705: 31.0.50; eglot--dumb-tryc Filters out too much Dmitry Gutov
2024-08-19  9:22 ` João Távora
2024-08-19 11:39   ` Dmitry Gutov
2024-08-19 12:59     ` João Távora
2024-08-20  2:08       ` Dmitry Gutov
2024-08-20  9:40         ` João Távora
2024-08-21  0:30           ` Dmitry Gutov
2024-08-21 16:52             ` João Távora
2024-08-22  0:41               ` Dmitry Gutov
2024-08-22 16:59                 ` João Távora
2024-08-22 23:16                   ` Dmitry Gutov
2024-08-23 10:23                     ` João Távora
2024-08-25  2:49                       ` Dmitry Gutov
2024-08-25  9:53                         ` João Távora
2024-08-25 15:56                           ` Dmitry Gutov
2024-08-25 23:40                           ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).