From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Brennan Vincent Newsgroups: gmane.emacs.bugs Subject: bug#68699: Eglot completion has stopped working in some cases Date: Thu, 25 Jan 2024 10:34:18 -0500 Message-ID: <87cytpig05.fsf@prescott.mail-host-address-is-not-set> References: <87mssutqm8.fsf@prescott.mail-host-address-is-not-set> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34783"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 68699@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 25 16:35:10 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rT1kz-0008ZG-QP for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 25 Jan 2024 16:35:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT1ko-0001Q2-7L; Thu, 25 Jan 2024 10:34:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT1km-0001Pr-C6 for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 10:34:56 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rT1km-00051d-36 for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 10:34:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rT1kr-0006HM-Ui for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 10:35:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Brennan Vincent Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Jan 2024 15:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68699 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.170619688524107 (code B ref -1); Thu, 25 Jan 2024 15:35:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 25 Jan 2024 15:34:45 +0000 Original-Received: from localhost ([127.0.0.1]:48908 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rT1ka-0006Gk-Iq for submit@debbugs.gnu.org; Thu, 25 Jan 2024 10:34:44 -0500 Original-Received: from lists.gnu.org ([2001:470:142::17]:50294) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rT1kY-0006GS-Ks for submit@debbugs.gnu.org; Thu, 25 Jan 2024 10:34:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rT1kJ-00011z-Rv for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 10:34:28 -0500 Original-Received: from smtp.umanwizard.com ([54.203.248.109]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rT1kI-0004vf-4F for bug-gnu-emacs@gnu.org; Thu, 25 Jan 2024 10:34:27 -0500 Original-Received: from localhost ([173.205.212.102]) by smtp.umanwizard.com ; 25 Jan 2024 15:34:22 +0000 X-Fes-Received-For: bug-gnu-emacs@gnu.org X-Fes-Received-From: In-Reply-To: X-Fes-Encrypted: true X-Fes-Ehlo-Domain: localhost Received-SPF: pass client-ip=54.203.248.109; envelope-from=brennan@umanwizard.com; helo=smtp.umanwizard.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:278858 Archived-At: The issue is fixed for me on latest master, which includes the patch you mentioned. Jo=C3=A3o T=C3=A1vora writes: > On Thu, Jan 25, 2024 at 12:43=E2=80=AFAM Jo=C3=A3o T=C3=A1vora wrote: >> >> On Wed, Jan 24, 2024 at 8:37=E2=80=AFPM Brennan Vincent wrote: >> >> > For example, in a Rust crate with the following main file: >> > >> > fn foo_len() { >> > } >> > >> > fn main() { >> > len >> > } >> >> I've reproduced this with latest master: >> >> ~/Source/Emacs/emacs/src/emacs -Q ~/MoreSource/Rust/hello/src/main.rs >> -f rust-ts-mode -f eglot >> >> where main.rs is the provided snippet. >> >> Pressing C-M-i with point after 'len' yields the error. >> >> The error only happens in partial-completion is in the completion-styles >> variable, so a workaround is to remove partial-completion from >> completion-styles, at least in Eglot enabled buffers. >> >> I will look now for the underlying cause. > > Stefan, this is down to partial-completion somehow thinking > that "\\'len" should match at least some LSP-provided > completion candidate, otherwise it's an "internal error" > > I wish I could turn off all the styles from the table but I can > only add to them. I simply cannot write a reasonable > try-completion thing for LSP completions. LSP completions > are really designed to be navigated using a company-like > popup. Without it they should almost always use the *Completions* > buffer, and rarely ever Emacs partial completion shenanigans. > > Nevertheless, I need to plug this bug somehow in Eglot. > > Brennan, can you try this patch I've just pushed? > > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el > index 511000927cf..c5fbf5eb9d5 100644 > --- a/lisp/progmodes/eglot.el > +++ b/lisp/progmodes/eglot.el > @@ -3060,9 +3060,13 @@ eglot--dumb-flex > finally (cl-return comp))) > > (defun eglot--dumb-allc (pat table pred _point) (funcall table pat pred = t)) > +(defun eglot--dumb-tryc (pat table pred point) > + (if-let ((probe (funcall table pat pred nil))) > + (cons probe (length probe)) > + (cons pat point))) > > (add-to-list 'completion-category-defaults '(eglot-capf (styles > eglot--dumb-flex))) > -(add-to-list 'completion-styles-alist '(eglot--dumb-flex ignore > eglot--dumb-allc)) > +(add-to-list 'completion-styles-alist '(eglot--dumb-flex > eglot--dumb-tryc eglot--dumb-allc)) > > (defun eglot-completion-at-point () > "Eglot's `completion-at-point' function." > > Jo=C3=A3o