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#73279: [PATCH] Eglot: use immediate-mode eglot--request for :completionItem/resolve Date: Sun, 15 Sep 2024 15:22:05 -0400 Message-ID: <87v7ywoh7m.fsf@taipei.mail-host-address-is-not-set> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13321"; mail-complaints-to="usenet@ciao.gmane.io" To: 73279@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 15 21:23:09 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 1spupw-0003Iq-Ru for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 15 Sep 2024 21:23:08 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1spuph-0006UK-Id; Sun, 15 Sep 2024 15:22:53 -0400 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 1spupf-0006U4-Fp for bug-gnu-emacs@gnu.org; Sun, 15 Sep 2024 15:22:51 -0400 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 1spupf-0001jc-7P for bug-gnu-emacs@gnu.org; Sun, 15 Sep 2024 15:22:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=Iv5igqIJYbHkqxVLOfROQl7hAGDLPbUJ5fB6vlsKCiA=; b=QDJaLDHR0YJ0PJCQZFWXySYLzwlSUkj3okZCCwRYAZhtbXpMDRifgniOUfR6AjIBX3uy1QNybnbTqBKI+5ZomOXgPBAtpVYlFMvk/FjqNfTUSR5fbNv2OTTTVpD/kCFY8JKj7d2PALcJgg/SOjK7dQJcNdGfYZQ7Use+ltnI5hqadLMAhGAGBsRrYogaHjeVP23JFa2kY7hbt+mytv9PhWtorvor4wifopSR9Dr7/KNtb0Rqh3C5QS1kIJUcgVZrZ1+9PVff7vhOtPfyIMfKy3B0e0CWRNh8rmNZEBO8eetG+vmwwse3NQ3RQkxLH2SCGr1T4i76BxDbRwTPgPDEoA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1spupq-0007iL-E2 for bug-gnu-emacs@gnu.org; Sun, 15 Sep 2024 15:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Brennan Vincent Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 15 Sep 2024 19:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 73279 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.172642814929582 (code B ref -1); Sun, 15 Sep 2024 19:23:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Sep 2024 19:22:29 +0000 Original-Received: from localhost ([127.0.0.1]:50525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spupJ-0007h4-Eo for submit@debbugs.gnu.org; Sun, 15 Sep 2024 15:22:29 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:49168) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1spupH-0007gw-M4 for submit@debbugs.gnu.org; Sun, 15 Sep 2024 15:22:28 -0400 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 1spup3-0006SY-OD for bug-gnu-emacs@gnu.org; Sun, 15 Sep 2024 15:22:15 -0400 Original-Received: from smtp.umanwizard.com ([54.203.248.109]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1spup1-0001gu-MH for bug-gnu-emacs@gnu.org; Sun, 15 Sep 2024 15:22:12 -0400 Original-Received: from localhost ([108.6.22.48]) by smtp.umanwizard.com ; 15 Sep 2024 19:22:07 +0000 X-Fes-Received-For: bug-gnu-emacs@gnu.org X-Fes-Received-From: X-Envelope-From: 0f861add92db18c6fde521a15fac48e7cbaa9cb1 Mon Sep 17 00:00:00 2001 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 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:291864 Archived-At: * lisp/progmodes/eglot.el: use immediate-mode eglot--request for :completionItem/resolve in eglot-completion-at-point. With the previous behavior, we are informing the language server of the modified state of the buffer after initially inserting the completion, but before fully resolving the completion item. This confuses rust-analyzer (and maybe others, I don't know) and causes it not to return the correct set of additionalTextEdits. A simple Rust program that reveals the issue follows. Put the point after HashSet and attempt to complete. With the previous behavior, the language server fails to tell us to insert "use std::collections::HashSet" at the top of the file. With the new behavior as of this commit, completion works successfully (as it did in emacs 29.4). struct S { x: T } impl S> { } fn main() {} --- lisp/progmodes/eglot.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 82e99a2c920..e9de099d2cd 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -3229,7 +3229,9 @@ eglot-completion-at-point :resolveProvider) (plist-get lsp-comp :data)) (eglot--request server :completionItem/resolve - lsp-comp :cancel-on-input t) + lsp-comp + :cancel-on-input t + :immediate t) lsp-comp)))))) (when (and (consp eglot--capf-session) (= (car bounds) (car (nth 0 eglot--capf-session))) -- 2.45.2