Received: (at 73857) by debbugs.gnu.org; 13 Feb 2025 10:21:26 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 13 05:21:26 2025 Received: from localhost ([127.0.0.1]:40751 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tiWLW-00063c-2e for submit <at> debbugs.gnu.org; Thu, 13 Feb 2025 05:21:26 -0500 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]:59721) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <joaotavora@HIDDEN>) id 1tiWLT-00063M-GH for 73857 <at> debbugs.gnu.org; Thu, 13 Feb 2025 05:21:24 -0500 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-2bc659753d0so99626fac.3 for <73857 <at> debbugs.gnu.org>; Thu, 13 Feb 2025 02:21:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739442077; x=1740046877; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=f0pNesh/TcTRU8BhA9fCb7w2P7haUTyurp9msekbBJI=; b=M40D2OExxRw9rnxvqwP9TuRNW6PKYhb781mZJfQRHUVGCkQzxUlereKUcsXgbQfvh/ H0CDuF722xnJFtnFP4BL8OdfmNdzSxFfsVKnNDsB3dzLMo65tCkzHFPbvMh+XHjFjhoh hZ/2XLehgOT419eIQ62F3JsPByv9pS8iffahu/gJGbPviXCi+6b43EfncCXVj2169PdC +LXeeOSbsGO/C5yn8Y9kF6xnQYo2fnerYsZ6ZvcZiajwSrcS0lRofrqOT9p2JRC69tUg hTLlI8xPv0Hwtx6c7fjdTsl+OURbIxE3Js0Yd5bvGrWeBPnrEStBw/Vy/fsYjpXywa5T yOaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739442077; x=1740046877; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f0pNesh/TcTRU8BhA9fCb7w2P7haUTyurp9msekbBJI=; b=N7Pa1fk70yUY0enXd4hla2y9GDpT+H0YVjnX1WfGxSaquWMv7kKItyZvmDNKZ7OXgg scAhM30jgEipkKKBPVaLXcjN3AHb66BfNeyn3gtLY88HRjWZHzEv7bye80rNXIjZDYm3 i93PDWOb/xTKGSVU2+0cXFAJfGQ4GCjPeAj9d2vfrjuD5kMC5ExAWxnO0qOz5YMC2XTA y3iCg710Yferv7xQQS9IBfd8u1SToPVf23s+WcaKtXmucZItQmc01NZVDYzowfP2NIsc tSEMzdPjtMlkYP+iTFrN+4Gkxy5pVT9oHETPVueE4yqrIMV0ao99Q0YEUzRR6KR5iZfD fEdg== X-Forwarded-Encrypted: i=1; AJvYcCX9P6FHENwvoUbJSOpXJoIUT5xlaamWSFIbLiBA+gUXeMZ7EhBh+/QfIqiU1IZux5b63cszdw==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yw6swgx8sP5ZiXHsb6Xkn5jTwN0qnNLS6Tki2VDZ03Yo1b/S0YR i4NEtVDwjS6g0k4xhgI0QGiTD8eabSAon71jmKU5fI+c8g7822gNtbfmFpXUR/P5yNCf3QshlWI E620/F2xAih2YjHByXz5eNnNLBsgZ2Psj X-Gm-Gg: ASbGncs0uh0s0RrPUwGX3+ANa8CMs0kSyaBJFZgXT/bPFHemiLX7E5+eNgzUbL/2qoW 3HeEMTnNn6Co179ZXFAL/O/Q9jZ6e062stS3EhSfVYwfrCzPqn15r4F9FWGR/wgJOvMBiguE= X-Google-Smtp-Source: AGHT+IHKDsuare7SM0dzPXIOoeK/WihX/3o840/1OR8MoajD9PFDWL4puqRr/N3SAqKM0vVVI6l+gLTjoQ+gJnBfCzY= X-Received: by 2002:a05:6870:e0d3:b0:29f:af5b:ef49 with SMTP id 586e51a60fabf-2b8d651589bmr4362300fac.10.1739442077028; Thu, 13 Feb 2025 02:21:17 -0800 (PST) MIME-Version: 1.0 References: <CAKHgf3D4F_OBQaDqZ_cDFCzEUXNqQFPUXbTDxDVQgJ0e=viNTQ@HIDDEN> <86plnynecv.fsf@HIDDEN> <86v7x5yhl8.fsf@HIDDEN> <CALDnm53xp0EEfcdysHtr4cz18WNkMf7J-PBNuA0pjCnBgFUoxA@HIDDEN> <4ae8bd3e-1c7f-4ab5-a06d-76023b1e6bc5@HIDDEN> <CADwFkmk3UQ2tLMa_7V3ZffLoSNzVRnQFRwnwmSV4uudF9YyJ6g@HIDDEN> In-Reply-To: <CADwFkmk3UQ2tLMa_7V3ZffLoSNzVRnQFRwnwmSV4uudF9YyJ6g@HIDDEN> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN> Date: Thu, 13 Feb 2025 10:21:19 +0000 X-Gm-Features: AWEUYZlE61Dqygl4Of9N_trpZYJsgidWi7f7FRUbcHabZEDKdF5yoNpiPoUldcA Message-ID: <CALDnm53HTjXTVfKyqjgOGXboJpGWYtWvP9faDFBivbzJ_4ju1g@HIDDEN> Subject: Re: bug#73857: [PATCH] * lisp/progmodes/eglot.el: add support for insertReplaceEdit To: Stefan Kangas <stefankangas@HIDDEN> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 1.7 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: I've added a variation on Casey's patch, perhaps I forgot to send email to close this bug: commit 1143cf09a339d57051a4341103c9e342d8876649 Author: João Távora Date: Mon Jan 20 18:58:05 2025 +0000 Content analysis details: (1.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 URIBL_SBL_A Contains URL's A record listed in the Spamhaus SBL blocklist [URIs: gutov.dev] 0.6 URIBL_SBL Contains an URL's NS IP listed in the Spamhaus SBL blocklist [URIs: gutov.dev] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (joaotavora[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2001:4860:4864:20:0:0:0:2f listed in] [list.dnswl.org] 1.0 FREEMAIL_REPLY From and body contain different freemails X-Debbugs-Envelope-To: 73857 Cc: Dmitry Gutov <dmitry@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>, 73857 <at> debbugs.gnu.org, kcbanner@HIDDEN X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.3 (/) I've added a variation on Casey's patch, perhaps I forgot to send email to close this bug: commit 1143cf09a339d57051a4341103c9e342d8876649 Author: Jo=C3=A3o T=C3=A1vora <joaotavora@HIDDEN> Date: Mon Jan 20 18:58:05 2025 +0000 Eglot: add support for insertReplaceEdit (bug#73857) * lisp/progmodes/eglot.el (eglot-server-programs): Mention zig-ts-mode. (eglot--lsp-interface-alist): Describe 'InsertReplaceEdit'. (eglot-client-capabilities): Advertise 'insertReplaceSupport'. (eglot-completion-at-point): Consider 'InsertReplaceEdit'. (eglot--apply-text-edits): Consider 'InsertReplaceEdit'. * test/lisp/progmodes/eglot-tests.el (eglot-test-zig-insert-replace-completion): New test. Special thanks to kcbanner@HIDDEN Added a zig test, too. On Thu, Feb 13, 2025 at 10:18=E2=80=AFAM Stefan Kangas <stefankangas@gmail.= com> wrote: > > Dmitry Gutov <dmitry@HIDDEN> writes: > > > Hi! > > > > On 02/11/2024 15:22, Jo=C3=A3o T=C3=A1vora wrote: > >> First, the patch looks good. I haven't been able to test it, but it > >> looks good, very good even. > >> The issue seems to be valid, and I've confirmed it, but I don't > >> fully understand it. Here, I find it somewhat dissatisfying that > >> what would seem to be a client-side issue (i.e. a bug in Eglot) shoul= d > >> be "fixed" by adding a feature so as to somehow circumvent the > >> problem. > >> But another possible explanation is that the issue is not a bug in Egl= ot > >> but a bug in certain servers (such as rust-analyzer) which given > >> the reasonable/common absence of a capability in the client (the one > >> that's being proposed by Casey) utilizes Eglot's current capabilities > >> in a suboptimal way that triggers a problem. > >> In that case -- which would have to be confirmed -- fixing the server > >> or adding the capability to the client are two equally valid alternati= ves > >> to solve this. We seem to have the latter in the patch. > >> When I find the time I will try to test this patch, unless someone > >> beats me to it with a convincing test (even better a convincing > >> automated test in eglot-tests.el). Such a person could be > >> Dmitry, who has worked on Eglot completion logic before. I've > >> added him to CC. > > > > I agree that such a change should come with automated test(s). Happy to= provide > > pointers, or look at writing that myself in a little while. > > > > Speaking of client-side issue, it might as well be. Or it is possible t= hat our > > original expectations were wrong, and the protocol expected the suffix = to never > > be replaced using the original convention. Now the next extension allow= s us to > > ask the servers to do that instead. > > > > Regarding capabilities, though, it seems the editors that support the e= xtension, > > so far, all include the ability to configure which of the behaviors (in= sert or > > replace) will be used, with a way to invoke the non-default behavior us= ing a > > combination like Shift+Enter. > > > > Is that something we want? Or, to put it differently, are we sure that = the > > "insert" behavior won't be preferred at least in some contexts (only de= termined > > by the user)? > > > > The protocol doc says this: > > > > * Most editors support two different operations when accepting a comp= letion > > * item. One is to insert a completion text and the other is to replac= e an > > * existing text with a completion text. Since this can usually not be > > * predetermined by a server it can report both ranges. > > > > Examples of configurability: > > > > * VS Code: > > https://github.com/microsoft/language-server-protocol/issues/1260#i= ssuecomment-833014788 > > (link to a video in a comment) > > * Sublime: https://github.com/sublimelsp/LSP/pull/1809 > > * [dbaeumer about Eclipse]: > > https://github.com/microsoft/language-server-protocol/issues/1260#i= ssuecomment-836775280 > > > > I'm not sure which method should be used in our completion UI to say "f= lip > > default this time", but maybe a user option would help. > > Casey, I see that there were several followups to your proposed patch. > > Did you make any progress with it? Thanks in advance. --=20 Jo=C3=A3o T=C3=A1vora
bug-gnu-emacs@HIDDEN
:bug#73857
; Package emacs
.
Full text available.Received: (at 73857) by debbugs.gnu.org; 13 Feb 2025 10:18:44 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 13 05:18:44 2025 Received: from localhost ([127.0.0.1]:40738 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1tiWIt-0005sl-9W for submit <at> debbugs.gnu.org; Thu, 13 Feb 2025 05:18:43 -0500 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]:51328) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1tiWIZ-0005rw-E4 for 73857 <at> debbugs.gnu.org; Thu, 13 Feb 2025 05:18:23 -0500 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-5de849a0b6cso1216881a12.2 for <73857 <at> debbugs.gnu.org>; Thu, 13 Feb 2025 02:18:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739441897; x=1740046697; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=+F+9B+dcW751EDYsxlxaX66fsRe6p3opk5cmkRazRyo=; b=DV7u8eD3egVraU+q47BijZFIusYZ5KTm2X1Uz9Vr1+oHyRvq820CI0yirggqSRjME7 3H6YbyqeCyuqm8Wut+vWQ8zFd+80dSvdYvVlEsPx9iB5Qr8datiq/4Xzxnv0Bm+xg1OM +Q3biijcMUPN8PGIm2k02NLG2TdPwrH+BU5GcLdQiO+qrQ8OCKaPWoWkthMIcYGAp2BG Nxvuh5DXgSlD1YVNy/4UknMSpU8A2TWZExfcHiQ2q5hJombcuZaD912ZBYoxPHSe3pLH tahtfNafpnYPRBzgjEcCF0u0V1ABUsBK768I6QTotQX10xrMtAhW9szWU0+ySI/zBWTM Q2PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739441897; x=1740046697; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=+F+9B+dcW751EDYsxlxaX66fsRe6p3opk5cmkRazRyo=; b=pgeJz5JgSbKlyINhJ5EIBEFpGg244oSOsz2kBNQsN0wG92C/HvQgsWR5QsxZmVeGJh bjVCn4UaXVF5KrRd7i+YYkl68L55NCqBa0zDJxAknx85LUyVHT0tq6G42TnibAxaeYMi D3HdSaM5svlh8MPBJkSgcgtg1epapnjlF55gA0Ara//VLSSBAzhbpLkgFH4VGJtUcbyy /aqBEeJz+eqNjBfAy8WPoVCRSVD7s8l+Zx106nMgHhuAnVCRj4JExabp1q+zGQaniiHN 1ayWREaDYDAXYfigEjBG7+QM5E1WB+wXQy1ax7ZnBCk24PQ7haEeUh3+OvObLlHN/0CL pEhQ== X-Forwarded-Encrypted: i=1; AJvYcCWshBHBo52JrHpCr1Qhtm/Vye3U6z+2nZHoOaHgzF4ENeL4JJqQB6qfbYbWpXx0kp9Leb6r0Q==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yy22AEwNR+vNNgj4L0TnjXUb+JoZr8Z4mPk72s8wkhA8a9H92Kq Z+PwqiS54pEvtrY1T/NSsGZK/66uQNFecv3xEeZmSyW8IiCAmXKmN7wZmDtARyi9AFp5DgyGFdr EIFHcjkoSFf0nEnSBNh9n6Y5p63PvtJjfuc169g== X-Gm-Gg: ASbGncs2llB0JE/ZcSVn4G/iasM3DadKrCDyO8fB1do4fcfOSRNDsl8frX44R/upQVf 1rgzSsKKvUk7FTW8dHe8JC94ze/SdVo+IoyJAhVh2ibwfJdA8tNDCedLWKRl3G3yK0V6QjG9jEq w= X-Google-Smtp-Source: AGHT+IEr7xFqmdQSJvSMzCcYdsweqM5PSxkeHCDU2QCzQc9f3K7kjfcBpJOfOTd58nDglpgEVDVukWe0WVS4jOPTzwc= X-Received: by 2002:a05:6402:350b:b0:5dc:74f1:8a32 with SMTP id 4fb4d7f45d1cf-5dec9fcb6c8mr1911124a12.28.1739441896908; Thu, 13 Feb 2025 02:18:16 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 13 Feb 2025 02:18:16 -0800 From: Stefan Kangas <stefankangas@HIDDEN> In-Reply-To: <4ae8bd3e-1c7f-4ab5-a06d-76023b1e6bc5@HIDDEN> References: <CAKHgf3D4F_OBQaDqZ_cDFCzEUXNqQFPUXbTDxDVQgJ0e=viNTQ@HIDDEN> <86plnynecv.fsf@HIDDEN> <86v7x5yhl8.fsf@HIDDEN> <CALDnm53xp0EEfcdysHtr4cz18WNkMf7J-PBNuA0pjCnBgFUoxA@HIDDEN> <4ae8bd3e-1c7f-4ab5-a06d-76023b1e6bc5@HIDDEN> MIME-Version: 1.0 Date: Thu, 13 Feb 2025 02:18:16 -0800 X-Gm-Features: AWEUYZleheZ0hjEDkcjHBxV_m1UpkUQ41ffT7mRYj9L6G239iZCDQR4sgA3BlGk Message-ID: <CADwFkmk3UQ2tLMa_7V3ZffLoSNzVRnQFRwnwmSV4uudF9YyJ6g@HIDDEN> Subject: Re: bug#73857: [PATCH] * lisp/progmodes/eglot.el: add support for insertReplaceEdit To: Dmitry Gutov <dmitry@HIDDEN> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 73857 Cc: kcbanner@HIDDEN, Eli Zaretskii <eliz@HIDDEN>, =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>, 73857 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.3 (/) Dmitry Gutov <dmitry@HIDDEN> writes: > Hi! > > On 02/11/2024 15:22, Jo=C3=A3o T=C3=A1vora wrote: >> First, the patch looks good. I haven't been able to test it, but it >> looks good, very good even. >> The issue seems to be valid, and I've confirmed it, but I don't >> fully understand it. Here, I find it somewhat dissatisfying that >> what would seem to be a client-side issue (i.e. a bug in Eglot) should >> be "fixed" by adding a feature so as to somehow circumvent the >> problem. >> But another possible explanation is that the issue is not a bug in Eglot >> but a bug in certain servers (such as rust-analyzer) which given >> the reasonable/common absence of a capability in the client (the one >> that's being proposed by Casey) utilizes Eglot's current capabilities >> in a suboptimal way that triggers a problem. >> In that case -- which would have to be confirmed -- fixing the server >> or adding the capability to the client are two equally valid alternative= s >> to solve this. We seem to have the latter in the patch. >> When I find the time I will try to test this patch, unless someone >> beats me to it with a convincing test (even better a convincing >> automated test in eglot-tests.el). Such a person could be >> Dmitry, who has worked on Eglot completion logic before. I've >> added him to CC. > > I agree that such a change should come with automated test(s). Happy to p= rovide > pointers, or look at writing that myself in a little while. > > Speaking of client-side issue, it might as well be. Or it is possible tha= t our > original expectations were wrong, and the protocol expected the suffix to= never > be replaced using the original convention. Now the next extension allows = us to > ask the servers to do that instead. > > Regarding capabilities, though, it seems the editors that support the ext= ension, > so far, all include the ability to configure which of the behaviors (inse= rt or > replace) will be used, with a way to invoke the non-default behavior usin= g a > combination like Shift+Enter. > > Is that something we want? Or, to put it differently, are we sure that th= e > "insert" behavior won't be preferred at least in some contexts (only dete= rmined > by the user)? > > The protocol doc says this: > > * Most editors support two different operations when accepting a comple= tion > * item. One is to insert a completion text and the other is to replace = an > * existing text with a completion text. Since this can usually not be > * predetermined by a server it can report both ranges. > > Examples of configurability: > > * VS Code: > https://github.com/microsoft/language-server-protocol/issues/1260#iss= uecomment-833014788 > (link to a video in a comment) > * Sublime: https://github.com/sublimelsp/LSP/pull/1809 > * [dbaeumer about Eclipse]: > https://github.com/microsoft/language-server-protocol/issues/1260#iss= uecomment-836775280 > > I'm not sure which method should be used in our completion UI to say "fli= p > default this time", but maybe a user option would help. Casey, I see that there were several followups to your proposed patch. Did you make any progress with it? Thanks in advance.
bug-gnu-emacs@HIDDEN
:bug#73857
; Package emacs
.
Full text available.Received: (at 73857) by debbugs.gnu.org; 4 Nov 2024 00:25:11 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 03 19:25:11 2024 Received: from localhost ([127.0.0.1]:35966 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t7ku7-0003Om-61 for submit <at> debbugs.gnu.org; Sun, 03 Nov 2024 19:25:11 -0500 Received: from fout-b7-smtp.messagingengine.com ([202.12.124.150]:60491) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <dmitry@HIDDEN>) id 1t7ku2-0003JV-Sj for 73857 <at> debbugs.gnu.org; Sun, 03 Nov 2024 19:25:10 -0500 Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfout.stl.internal (Postfix) with ESMTP id 89D6911400DB; Sun, 3 Nov 2024 19:25:01 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Sun, 03 Nov 2024 19:25:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1730679901; x=1730766301; bh=4Fd4rLW80dlv90eHwAAAKpnbnJQpYqAG+uG8Ls27qtk=; b= pHOG3ripNt3ubZpfttvxUsBtNyJJCmaS/seag1J4st/r6Y4BQfhgImrMJwhcmpj9 Ymubm6lFaO7Rv7qusCoiUREeWriy24S1vOmPs05bY3nCk+TZoG2BbJJzs+EwTLBH QaCqtOJWeezXeH7HeCP2xtuUA1KniAfJVFSBviH5zlqnEV69UtGb5ZxWbrv+MZGa gwVy1ff1QzhVC9j7iQHWq3mpECOF/UNXMHPqKeaceSMtVRB3C0CEswzJ1gHDBzMS dt+vBPsqIWIg5xfJk96naP9imJfgW3DoB4PtMmrIgbr5qI1ASTPWpHvo8cVRNqqz 9CpkgbRPE06L8+CZyVUwtA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1730679901; x= 1730766301; bh=4Fd4rLW80dlv90eHwAAAKpnbnJQpYqAG+uG8Ls27qtk=; b=L 7BFjIqIvsY60B6/ago2Ldo87VL+0gh66iNhMxKkqp1aZVvdaKvqXVzx6IqacZbWa D+K+i1YR6I2FCqEjSzbVwwjp1YT4kvWWEnjpANG6z7Ud5X5QEb1VPqW0MtSER2Jf oLXPqOORtC3gnTsnMK11tGjdJcxw2SOT+6V3S0sO9sfMb5LdHbhCKgtmkOUt4iyi DGqk+oOT3iY1yiH7qKUXRkZoh0MSJt7IVU6xqEsSCjEQhqGsqDZffjshfL2mRDkG YX0DjmRTVJ9EfQgS2DK4+mFcuS8mkX7GOlOqmkKDKtTFrfnj/cy92ogGlkZ6RIti ZQAS9oFwXDeMqCteXrnmA== X-ME-Sender: <xms:XRQoZxoJq4hF_8EaDCpjG3FDwnI1FSMioiHAH4M54xxpG5IEHyE_Wg> <xme:XRQoZzpY7hLATsFmpLQFM6vUo1Ebsr1s8sUqRGtusaAk7HNJCyNfWC9lF0kztsFb4 9vUrCoRPW2XmswoMLI> X-ME-Received: <xmr:XRQoZ-MEmMtzciiXeJEWMe3je7Fz_qFDHabFgyeuwKP_mhN4RNnedtKmKi2RCBZgWnp3> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdelhedgvdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdej necuhfhrohhmpeffmhhithhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdrug gvvheqnecuggftrfgrthhtvghrnhepfedvjeeviefffeeukeelveeikeegtddtveeileev gfdvgffhtdfggeeffeegiefgnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumhhithhrhies ghhuthhovhdruggvvhdpnhgspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpd hrtghpthhtohepjhhorghothgrvhhorhgrsehgmhgrihhlrdgtohhmpdhrtghpthhtohep vghlihiisehgnhhurdhorhhgpdhrtghpthhtohepkhgtsggrnhhnvghrsehgmhgrihhlrd gtohhmpdhrtghpthhtohepjeefkeehjeesuggvsggsuhhgshdrghhnuhdrohhrgh X-ME-Proxy: <xmx:XRQoZ85yReStjfunX1v-FgvJhyk7xbk1IOi8PNQ26DXqTUmFHe3B9Q> <xmx:XRQoZw664kyZrxvxZCCbbT3hvBuyVmoOu4-XYOFl2bA-Qy7ST9trRw> <xmx:XRQoZ0hogJm2lsLztKTBjeSZZo8_80PKX27Ovmz1ns-_xTZzXE-7eA> <xmx:XRQoZy6oWr5RyboxrRJU9_aaJ2NmwmxkIk7m0WFzT7fIMEHqInEnqA> <xmx:XRQoZ73Ouw0ClcpSra6ut13XMTrTvOT64vr9n2F5SGJTY-4l_W-l2NSi> Feedback-ID: i07de48aa:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 3 Nov 2024 19:24:59 -0500 (EST) Message-ID: <4ae8bd3e-1c7f-4ab5-a06d-76023b1e6bc5@HIDDEN> Date: Mon, 4 Nov 2024 02:24:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#73857: [PATCH] * lisp/progmodes/eglot.el: add support for insertReplaceEdit To: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN>, Eli Zaretskii <eliz@HIDDEN> References: <CAKHgf3D4F_OBQaDqZ_cDFCzEUXNqQFPUXbTDxDVQgJ0e=viNTQ@HIDDEN> <86plnynecv.fsf@HIDDEN> <86v7x5yhl8.fsf@HIDDEN> <CALDnm53xp0EEfcdysHtr4cz18WNkMf7J-PBNuA0pjCnBgFUoxA@HIDDEN> Content-Language: en-US From: Dmitry Gutov <dmitry@HIDDEN> In-Reply-To: <CALDnm53xp0EEfcdysHtr4cz18WNkMf7J-PBNuA0pjCnBgFUoxA@HIDDEN> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 73857 Cc: kcbanner@HIDDEN, 73857 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.3 (/) Hi! On 02/11/2024 15:22, João Távora wrote: > First, the patch looks good. I haven't been able to test it, but it > looks good, very good even. > > The issue seems to be valid, and I've confirmed it, but I don't > fully understand it. Here, I find it somewhat dissatisfying that > what would seem to be a client-side issue (i.e. a bug in Eglot) should > be "fixed" by adding a feature so as to somehow circumvent the > problem. > > But another possible explanation is that the issue is not a bug in Eglot > but a bug in certain servers (such as rust-analyzer) which given > the reasonable/common absence of a capability in the client (the one > that's being proposed by Casey) utilizes Eglot's current capabilities > in a suboptimal way that triggers a problem. > > In that case -- which would have to be confirmed -- fixing the server > or adding the capability to the client are two equally valid alternatives > to solve this. We seem to have the latter in the patch. > > When I find the time I will try to test this patch, unless someone > beats me to it with a convincing test (even better a convincing > automated test in eglot-tests.el). Such a person could be > Dmitry, who has worked on Eglot completion logic before. I've > added him to CC. I agree that such a change should come with automated test(s). Happy to provide pointers, or look at writing that myself in a little while. Speaking of client-side issue, it might as well be. Or it is possible that our original expectations were wrong, and the protocol expected the suffix to never be replaced using the original convention. Now the next extension allows us to ask the servers to do that instead. Regarding capabilities, though, it seems the editors that support the extension, so far, all include the ability to configure which of the behaviors (insert or replace) will be used, with a way to invoke the non-default behavior using a combination like Shift+Enter. Is that something we want? Or, to put it differently, are we sure that the "insert" behavior won't be preferred at least in some contexts (only determined by the user)? The protocol doc says this: * Most editors support two different operations when accepting a completion * item. One is to insert a completion text and the other is to replace an * existing text with a completion text. Since this can usually not be * predetermined by a server it can report both ranges. Examples of configurability: * VS Code: https://github.com/microsoft/language-server-protocol/issues/1260#issuecomment-833014788 (link to a video in a comment) * Sublime: https://github.com/sublimelsp/LSP/pull/1809 * [dbaeumer about Eclipse]: https://github.com/microsoft/language-server-protocol/issues/1260#issuecomment-836775280 I'm not sure which method should be used in our completion UI to say "flip default this time", but maybe a user option would help.
bug-gnu-emacs@HIDDEN
:bug#73857
; Package emacs
.
Full text available.Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 73857) by debbugs.gnu.org; 2 Nov 2024 13:21:48 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 02 09:21:48 2024 Received: from localhost ([127.0.0.1]:53495 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t7E4Z-0002sj-Lf for submit <at> debbugs.gnu.org; Sat, 02 Nov 2024 09:21:48 -0400 Received: from mail-oo1-f53.google.com ([209.85.161.53]:47344) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <joaotavora@HIDDEN>) id 1t7E4V-0002sa-8c for 73857 <at> debbugs.gnu.org; Sat, 02 Nov 2024 09:21:45 -0400 Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-5ebc22e6362so1312523eaf.2 for <73857 <at> debbugs.gnu.org>; Sat, 02 Nov 2024 06:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730553637; x=1731158437; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UxJlCRGraY6wGHWkjkpGb+QGQ08Epoj9Zshs9kXLwZg=; b=OMYPM7jzisPl6lwTGQJ9BwjcVoBzfwxLMjObr6+rOpDaejXjJjqRDy1cQgflQytWKJ hPYCR3tw7MJMsjDINLzoIgunEA7z+n/fpy168tHcjC+gRWQ5WRXXDVUQqin20YlwWZvO ejvSO8FFj9W1gl/HVDtZhMjXFDnLCBzTvoi2NGTiuu5kZpmFW5/t4Q/5+8NUHM8DdJC1 WtTWsozlzHviI10o8Iw+Hi/aDsEy5uJbbe9IIZ8OizUd296Qa7H3knYLnacdh/xPhyG1 scHE2R43+OUavdd146opNGLpTU8rBdIZfLP6a+Cj+oouDBPkjyvp48TvcojGdvk4NLjK ELJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730553637; x=1731158437; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UxJlCRGraY6wGHWkjkpGb+QGQ08Epoj9Zshs9kXLwZg=; b=Xe8X+0gdF3tWhP9SaHaif9R1TNZWxxk0UBl+rZfpkAEZUIxP4fs8o5kxmcKy7qin4x EthbUsYjbsl4YcMGQI6WhNG6aZ/u7vnyGrT0UL3WSLliLhmCWEE3/IzA6gk0QcLaY0I7 ca4YeZpZAcg8P2P7RGgWhIFUFPvP9CKPcj3jaXIzWOnjcqIptOXyLw07LuyeKrRSMPEI 8UWL8T+WIF6GZAt6T0dN9G18qaUPELMoeLg6U41QbBA6mDXkH0IvIMpvvPgPibCPFodd SS9dUACjSkXhvvf4W33aDNymCf/CLxx8x1Qtg3RTQKM35v6FYOzE+bq2Le/0h3V9CV2g UUVg== X-Forwarded-Encrypted: i=1; AJvYcCUnSIH8jKsPbxgIq9IWXFNpyhMPRmphMAoeo6IoKNRNHJeuaXihJFu4fetBrsBRW4kDrSLudA==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzLSVkFD8Tati7NgCKphHxQ+vqkoOGXGQi1le1Zfenrtg36a5SZ b8C5hn7l2EI2bMq4THf/ttE7ZgsZPgEhWcOE97RyK7xaSJQ5STwW1Q7gDOhw7IedFvXIu003y+L gvdnOw2NjJEAk4HqLErcyE7Why40= X-Google-Smtp-Source: AGHT+IGZ+D3IZeVllS3devgD080R9Qh5xavkyxrzEL5ZLm0ooAvvoBRYxBi3WTKSDlp5l0HTHOGabzeVPy0JnqjBXf8= X-Received: by 2002:a05:6820:1c9d:b0:5e5:941c:ca5a with SMTP id 006d021491bc7-5ec6da771ebmr6573326eaf.1.1730553637361; Sat, 02 Nov 2024 06:20:37 -0700 (PDT) MIME-Version: 1.0 References: <CAKHgf3D4F_OBQaDqZ_cDFCzEUXNqQFPUXbTDxDVQgJ0e=viNTQ@HIDDEN> <86plnynecv.fsf@HIDDEN> <86v7x5yhl8.fsf@HIDDEN> In-Reply-To: <86v7x5yhl8.fsf@HIDDEN> From: =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN> Date: Sat, 2 Nov 2024 13:22:16 +0000 Message-ID: <CALDnm53xp0EEfcdysHtr4cz18WNkMf7J-PBNuA0pjCnBgFUoxA@HIDDEN> Subject: Re: bug#73857: [PATCH] * lisp/progmodes/eglot.el: add support for insertReplaceEdit To: Eli Zaretskii <eliz@HIDDEN>, Dmitry Gutov <dmitry@HIDDEN> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 73857 Cc: kcbanner@HIDDEN, 73857 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.3 (/) First, the patch looks good. I haven't been able to test it, but it looks good, very good even. The issue seems to be valid, and I've confirmed it, but I don't fully understand it. Here, I find it somewhat dissatisfying that what would seem to be a client-side issue (i.e. a bug in Eglot) should be "fixed" by adding a feature so as to somehow circumvent the problem. But another possible explanation is that the issue is not a bug in Eglot but a bug in certain servers (such as rust-analyzer) which given the reasonable/common absence of a capability in the client (the one that's being proposed by Casey) utilizes Eglot's current capabilities in a suboptimal way that triggers a problem. In that case -- which would have to be confirmed -- fixing the server or adding the capability to the client are two equally valid alternatives to solve this. We seem to have the latter in the patch. When I find the time I will try to test this patch, unless someone beats me to it with a convincing test (even better a convincing automated test in eglot-tests.el). Such a person could be Dmitry, who has worked on Eglot completion logic before. I've added him to CC. Jo=C3=A3o On Sat, Nov 2, 2024 at 11:56=E2=80=AFAM Eli Zaretskii <eliz@HIDDEN> wrote: > > Ping! Jo=C3=A3o, any comments to the patch or the issue in general? > > > Cc: 73857 <at> debbugs.gnu.org > > Date: Fri, 18 Oct 2024 08:56:32 +0300 > > From: Eli Zaretskii <eliz@HIDDEN> > > > > > From: Casey Banner <kcbanner@HIDDEN> > > > Date: Thu, 17 Oct 2024 20:54:38 -0400 > > > > > > Since 3.16, LSP supports the capability `insertReplaceSupport`. This > > > allows textEdit to be an `InsertReplaceEdit` see: > > > (https://microsoft.github.io/language-server-protocol/specifications/= lsp/3.17/specification/#insertReplaceEdit) > > > > > > This patch adds support for this capability, and uses the `replace` > > > field of the `InsertReplaceEdit`. Original functionality (ie. > > > `TextEdit`) is preserved. > > > > > > The benefits of this were originally discussed here: > > > https://github.com/joaotavora/eglot/discussions/1456, but this is a s= ummary: > > > > > > Consider this file: > > > > > > ``` > > > const Foo =3D struct { > > > correct_name: u32, > > > }; > > > > > > fn example(foo: Foo) u32 { > > > return foo.correct_name; > > > } > > > ``` > > > > > > 1. Place the cursor on 6:22 (the _ in correct_name) > > > 2. Backspace once to delete the t > > > 3. Receive the following LSP message: `<-- textDocument/completion[20= ] {"jsonrpc":"2.0","id":20,"result": > > > {"isIncomplete":false,"items":[{"label":"correct_name","kind":5,"deta= il":"u32","documentation": > > > {"kind":"plaintext","value":""},"sortText":"2_correct_name","textEdit= ":{"range":{"start": > > > {"line":5,"character":15},"end":{"line":5,"character":21}},"newText":= "correct_name"}}]}}` > > > 4. Accept the completion > > > 5. The buffer now contains ` return foo.correct_name_name;` on lin= e 6 > > > > > > I expected it to replace the entire token, resulting in ` return f= oo.correct_name;`. > > > > > > Indeed with this patch applied (and an LSP that supports the > > > capability), the behaviour I expected is now what happens. > > > > > > This is the first real elisp that I've written besides configuration,= so > > > I'm not sure if this is the correct way, but it seems to work for me. > > > > > > Patch is attached. > > > > Thanks. > > > > Jo=C3=A3o, any comments? > > > > > From bbf79f95636d699ccf9ba7028e6c3dce23af2378 Mon Sep 17 00:00:00 200= 1 > > > From: kcbanner <kcbanner@HIDDEN> > > > Date: Thu, 17 Oct 2024 00:43:32 -0400 > > > Subject: [PATCH] * lisp/progmodes/eglot.el: add support for insertRep= laceEdit > > > > > > --- > > > lisp/progmodes/eglot.el | 25 +++++++++++++++++++------ > > > 1 file changed, 19 insertions(+), 6 deletions(-) > > > > > > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el > > > index 0a14146a245..8285506928f 100644 > > > --- a/lisp/progmodes/eglot.el > > > +++ b/lisp/progmodes/eglot.el > > > @@ -647,6 +647,7 @@ eglot--uri-path-allowed-chars > > > (:detail :deprecated :children)) > > > (TextDocumentEdit (:textDocument :edits) ()) > > > (TextEdit (:range :newText)) > > > + (InsertReplaceEdit (:newText :insert :replace)) > > > (VersionedTextDocumentIdentifier (:uri :version) ()) > > > (WorkDoneProgress (:kind) (:title :message :percentage :cancel= lable)) > > > (WorkspaceEdit () (:changes :documentChanges)) > > > @@ -959,7 +960,8 @@ eglot-client-capabilities > > > ["documentati= on" > > > "details" > > > "additionalT= extEdits"]) > > > - :tagSupport (:valueSet [1])) > > > + :tagSupport (:valueSet [1]) > > > + :insertReplaceSupport t) > > > :contextSupport t) > > > :hover (list :dynamicRegistration :json-fa= lse > > > :contentFormat (eglot--accept= ed-formats)) > > > @@ -3368,12 +3370,19 @@ eglot-completion-at-point > > > ;; state, _not_ the current "foo.bar". > > > (delete-region orig-pos (point)) > > > (insert (substring bounds-string (- orig-pos= (car bounds)))) > > > - (eglot--dbind ((TextEdit) range newText) tex= tEdit > > > - (pcase-let ((`(,beg . ,end) > > > + (eglot--dcase textEdit > > > + (((TextEdit) range newText) > > > + (pcase-let ((`(,beg . ,end) > > > (eglot-range-region range))) > > > (delete-region beg end) > > > (goto-char beg) > > > - (funcall (or snippet-fn #'insert) newTex= t)))) > > > + (funcall (or snippet-fn #'insert) newTex= t))) > > > + (((InsertReplaceEdit) newText replace) > > > + (pcase-let ((`(,beg . ,end) > > > + (eglot-range-region replace)= )) > > > + (delete-region beg end) > > > + (goto-char beg) > > > + (funcall (or snippet-fn #'insert) newTe= xt))))) > > > (snippet-fn > > > ;; A snippet should be inserted, but using p= lain > > > ;; `insertText'. This requires us to delete= the > > > @@ -3602,8 +3611,12 @@ eglot--apply-text-edits > > > (replace-buffer-contents temp))) > > > (when reporter > > > (eglot--reporter-update reporter (cl-incf do= ne)))))))) > > > - (mapcar (eglot--lambda ((TextEdit) range newText) > > > - (cons newText (eglot-range-region range 'marke= rs))) > > > + (mapcar (lambda (text-edit-or-insert-replace-edit) > > > + (eglot--dcase text-edit-or-insert-replace-edit > > > + (((TextEdit) range newText) > > > + (cons newText (eglot-range-region range 'ma= rkers))) > > > + (((InsertReplaceEdit) newText replace) > > > + (cons newText (eglot-range-region replace '= markers))))) > > > (reverse edits))) > > > (undo-amalgamate-change-group change-group) > > > (when reporter > > > -- > > > 2.46.0.windows.1 > > > > > > > > > > > -- Jo=C3=A3o T=C3=A1vora
bug-gnu-emacs@HIDDEN
:bug#73857
; Package emacs
.
Full text available.Received: (at 73857) by debbugs.gnu.org; 2 Nov 2024 11:57:00 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 02 07:57:00 2024 Received: from localhost ([127.0.0.1]:53378 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t7CkW-0000G4-3z for submit <at> debbugs.gnu.org; Sat, 02 Nov 2024 07:57:00 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59374) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1t7CkS-0000Ft-Qw for 73857 <at> debbugs.gnu.org; Sat, 02 Nov 2024 07:56:57 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1t7CkN-0002cJ-KQ; Sat, 02 Nov 2024 07:56:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=cYSU5jVI2TYElmRhjnDmlPiPcYMtAfBXuzfFsH59HOA=; b=PMzP8zyHkEoxV5iYehII QGppdodCd6lSbTCKnT1RXrFpAXuk6c8+nRHuM4zRZUKTntbINhyGrTVL7GG3CRH59Sn1YsqdLnkKx 9MCvXxCdFSf6rouyXaRyctxVld+5RLekPO0ITUREGAbXaBTisD+mItLIgwb2tx3Yk6ZQ+1fmUZs0j hBVrI0TFPn53zznAwASmXSCLxGCakL9pRG8ziLisnvD0AKKTfVygrcPFzT9aKp1BzIzrFJgI6H5zK zgAOOhxHilTXqzAtzC+nzJONRW5VJDCe0R+gU33YJaCzJzPqT9l4drwc6LknP3+Jxz7Tl1nNWOIzu EA55Ckld0JrF2Q==; Date: Sat, 02 Nov 2024 13:56:35 +0200 Message-Id: <86v7x5yhl8.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: joaotavora@HIDDEN In-Reply-To: <86plnynecv.fsf@HIDDEN> (message from Eli Zaretskii on Fri, 18 Oct 2024 08:56:32 +0300) Subject: Re: bug#73857: [PATCH] * lisp/progmodes/eglot.el: add support for insertReplaceEdit References: <CAKHgf3D4F_OBQaDqZ_cDFCzEUXNqQFPUXbTDxDVQgJ0e=viNTQ@HIDDEN> <86plnynecv.fsf@HIDDEN> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: 73857 Cc: kcbanner@HIDDEN, 73857 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.6 (--) Ping! João, any comments to the patch or the issue in general? > Cc: 73857 <at> debbugs.gnu.org > Date: Fri, 18 Oct 2024 08:56:32 +0300 > From: Eli Zaretskii <eliz@HIDDEN> > > > From: Casey Banner <kcbanner@HIDDEN> > > Date: Thu, 17 Oct 2024 20:54:38 -0400 > > > > Since 3.16, LSP supports the capability `insertReplaceSupport`. This > > allows textEdit to be an `InsertReplaceEdit` see: > > (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#insertReplaceEdit) > > > > This patch adds support for this capability, and uses the `replace` > > field of the `InsertReplaceEdit`. Original functionality (ie. > > `TextEdit`) is preserved. > > > > The benefits of this were originally discussed here: > > https://github.com/joaotavora/eglot/discussions/1456, but this is a summary: > > > > Consider this file: > > > > ``` > > const Foo = struct { > > correct_name: u32, > > }; > > > > fn example(foo: Foo) u32 { > > return foo.correct_name; > > } > > ``` > > > > 1. Place the cursor on 6:22 (the _ in correct_name) > > 2. Backspace once to delete the t > > 3. Receive the following LSP message: `<-- textDocument/completion[20] {"jsonrpc":"2.0","id":20,"result": > > {"isIncomplete":false,"items":[{"label":"correct_name","kind":5,"detail":"u32","documentation": > > {"kind":"plaintext","value":""},"sortText":"2_correct_name","textEdit":{"range":{"start": > > {"line":5,"character":15},"end":{"line":5,"character":21}},"newText":"correct_name"}}]}}` > > 4. Accept the completion > > 5. The buffer now contains ` return foo.correct_name_name;` on line 6 > > > > I expected it to replace the entire token, resulting in ` return foo.correct_name;`. > > > > Indeed with this patch applied (and an LSP that supports the > > capability), the behaviour I expected is now what happens. > > > > This is the first real elisp that I've written besides configuration, so > > I'm not sure if this is the correct way, but it seems to work for me. > > > > Patch is attached. > > Thanks. > > João, any comments? > > > From bbf79f95636d699ccf9ba7028e6c3dce23af2378 Mon Sep 17 00:00:00 2001 > > From: kcbanner <kcbanner@HIDDEN> > > Date: Thu, 17 Oct 2024 00:43:32 -0400 > > Subject: [PATCH] * lisp/progmodes/eglot.el: add support for insertReplaceEdit > > > > --- > > lisp/progmodes/eglot.el | 25 +++++++++++++++++++------ > > 1 file changed, 19 insertions(+), 6 deletions(-) > > > > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el > > index 0a14146a245..8285506928f 100644 > > --- a/lisp/progmodes/eglot.el > > +++ b/lisp/progmodes/eglot.el > > @@ -647,6 +647,7 @@ eglot--uri-path-allowed-chars > > (:detail :deprecated :children)) > > (TextDocumentEdit (:textDocument :edits) ()) > > (TextEdit (:range :newText)) > > + (InsertReplaceEdit (:newText :insert :replace)) > > (VersionedTextDocumentIdentifier (:uri :version) ()) > > (WorkDoneProgress (:kind) (:title :message :percentage :cancellable)) > > (WorkspaceEdit () (:changes :documentChanges)) > > @@ -959,7 +960,8 @@ eglot-client-capabilities > > ["documentation" > > "details" > > "additionalTextEdits"]) > > - :tagSupport (:valueSet [1])) > > + :tagSupport (:valueSet [1]) > > + :insertReplaceSupport t) > > :contextSupport t) > > :hover (list :dynamicRegistration :json-false > > :contentFormat (eglot--accepted-formats)) > > @@ -3368,12 +3370,19 @@ eglot-completion-at-point > > ;; state, _not_ the current "foo.bar". > > (delete-region orig-pos (point)) > > (insert (substring bounds-string (- orig-pos (car bounds)))) > > - (eglot--dbind ((TextEdit) range newText) textEdit > > - (pcase-let ((`(,beg . ,end) > > + (eglot--dcase textEdit > > + (((TextEdit) range newText) > > + (pcase-let ((`(,beg . ,end) > > (eglot-range-region range))) > > (delete-region beg end) > > (goto-char beg) > > - (funcall (or snippet-fn #'insert) newText)))) > > + (funcall (or snippet-fn #'insert) newText))) > > + (((InsertReplaceEdit) newText replace) > > + (pcase-let ((`(,beg . ,end) > > + (eglot-range-region replace))) > > + (delete-region beg end) > > + (goto-char beg) > > + (funcall (or snippet-fn #'insert) newText))))) > > (snippet-fn > > ;; A snippet should be inserted, but using plain > > ;; `insertText'. This requires us to delete the > > @@ -3602,8 +3611,12 @@ eglot--apply-text-edits > > (replace-buffer-contents temp))) > > (when reporter > > (eglot--reporter-update reporter (cl-incf done)))))))) > > - (mapcar (eglot--lambda ((TextEdit) range newText) > > - (cons newText (eglot-range-region range 'markers))) > > + (mapcar (lambda (text-edit-or-insert-replace-edit) > > + (eglot--dcase text-edit-or-insert-replace-edit > > + (((TextEdit) range newText) > > + (cons newText (eglot-range-region range 'markers))) > > + (((InsertReplaceEdit) newText replace) > > + (cons newText (eglot-range-region replace 'markers))))) > > (reverse edits))) > > (undo-amalgamate-change-group change-group) > > (when reporter > > -- > > 2.46.0.windows.1 > > > > > >
bug-gnu-emacs@HIDDEN
:bug#73857
; Package emacs
.
Full text available.Received: (at 73857) by debbugs.gnu.org; 18 Oct 2024 05:57:05 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 18 01:57:05 2024 Received: from localhost ([127.0.0.1]:36733 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t1fyy-0003tL-96 for submit <at> debbugs.gnu.org; Fri, 18 Oct 2024 01:57:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41492) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1t1fyw-0003sr-Hq for 73857 <at> debbugs.gnu.org; Fri, 18 Oct 2024 01:57:03 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1t1fyU-0002Fi-Rq; Fri, 18 Oct 2024 01:56:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=yu+ARsOcUPCKzb1obcFQfdClAUo0jQC9QZRhn8uI/YE=; b=PLxnkSFHz23JF9QFjXfB V8AvoGhz5LFJrjxJayF6F5y+HW413ed+BgpVeSFDvUZIA2eA5ruVYj2IH90GDYtRsKoSUWOS82ji/ 8RbBQQmV71rzBvmySN5Thq7zWvjv9TgSM0s0tIhRmika5ZLOaCuoXEByGQEUIS9G8X0HobWzrksmk SurmA1KjPideb82NSg7TQz5pGj6+J13UYgxQQB/8258jYc83Z+bYafCnerFFBfLiCIQQf/EhBNu2A 2fQ7pS3qeYWwwVXvHhyxmVItZW9gK6ZSUpPr313im+CSA3D2IKYxKAfajS/Inak/Tr5DeEjlvbZmR IzXi3RkE3sOc3Q==; Date: Fri, 18 Oct 2024 08:56:32 +0300 Message-Id: <86plnynecv.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Casey Banner <kcbanner@HIDDEN>, =?utf-8?B?Sm/Do28gVMOhdm9yYQ==?= <joaotavora@HIDDEN> In-Reply-To: <CAKHgf3D4F_OBQaDqZ_cDFCzEUXNqQFPUXbTDxDVQgJ0e=viNTQ@HIDDEN> (message from Casey Banner on Thu, 17 Oct 2024 20:54:38 -0400) Subject: Re: bug#73857: [PATCH] * lisp/progmodes/eglot.el: add support for insertReplaceEdit References: <CAKHgf3D4F_OBQaDqZ_cDFCzEUXNqQFPUXbTDxDVQgJ0e=viNTQ@HIDDEN> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 73857 Cc: 73857 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Casey Banner <kcbanner@HIDDEN> > Date: Thu, 17 Oct 2024 20:54:38 -0400 > > Since 3.16, LSP supports the capability `insertReplaceSupport`. This > allows textEdit to be an `InsertReplaceEdit` see: > (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#insertReplaceEdit) > > This patch adds support for this capability, and uses the `replace` > field of the `InsertReplaceEdit`. Original functionality (ie. > `TextEdit`) is preserved. > > The benefits of this were originally discussed here: > https://github.com/joaotavora/eglot/discussions/1456, but this is a summary: > > Consider this file: > > ``` > const Foo = struct { > correct_name: u32, > }; > > fn example(foo: Foo) u32 { > return foo.correct_name; > } > ``` > > 1. Place the cursor on 6:22 (the _ in correct_name) > 2. Backspace once to delete the t > 3. Receive the following LSP message: `<-- textDocument/completion[20] {"jsonrpc":"2.0","id":20,"result": > {"isIncomplete":false,"items":[{"label":"correct_name","kind":5,"detail":"u32","documentation": > {"kind":"plaintext","value":""},"sortText":"2_correct_name","textEdit":{"range":{"start": > {"line":5,"character":15},"end":{"line":5,"character":21}},"newText":"correct_name"}}]}}` > 4. Accept the completion > 5. The buffer now contains ` return foo.correct_name_name;` on line 6 > > I expected it to replace the entire token, resulting in ` return foo.correct_name;`. > > Indeed with this patch applied (and an LSP that supports the > capability), the behaviour I expected is now what happens. > > This is the first real elisp that I've written besides configuration, so > I'm not sure if this is the correct way, but it seems to work for me. > > Patch is attached. Thanks. João, any comments? > From bbf79f95636d699ccf9ba7028e6c3dce23af2378 Mon Sep 17 00:00:00 2001 > From: kcbanner <kcbanner@HIDDEN> > Date: Thu, 17 Oct 2024 00:43:32 -0400 > Subject: [PATCH] * lisp/progmodes/eglot.el: add support for insertReplaceEdit > > --- > lisp/progmodes/eglot.el | 25 +++++++++++++++++++------ > 1 file changed, 19 insertions(+), 6 deletions(-) > > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el > index 0a14146a245..8285506928f 100644 > --- a/lisp/progmodes/eglot.el > +++ b/lisp/progmodes/eglot.el > @@ -647,6 +647,7 @@ eglot--uri-path-allowed-chars > (:detail :deprecated :children)) > (TextDocumentEdit (:textDocument :edits) ()) > (TextEdit (:range :newText)) > + (InsertReplaceEdit (:newText :insert :replace)) > (VersionedTextDocumentIdentifier (:uri :version) ()) > (WorkDoneProgress (:kind) (:title :message :percentage :cancellable)) > (WorkspaceEdit () (:changes :documentChanges)) > @@ -959,7 +960,8 @@ eglot-client-capabilities > ["documentation" > "details" > "additionalTextEdits"]) > - :tagSupport (:valueSet [1])) > + :tagSupport (:valueSet [1]) > + :insertReplaceSupport t) > :contextSupport t) > :hover (list :dynamicRegistration :json-false > :contentFormat (eglot--accepted-formats)) > @@ -3368,12 +3370,19 @@ eglot-completion-at-point > ;; state, _not_ the current "foo.bar". > (delete-region orig-pos (point)) > (insert (substring bounds-string (- orig-pos (car bounds)))) > - (eglot--dbind ((TextEdit) range newText) textEdit > - (pcase-let ((`(,beg . ,end) > + (eglot--dcase textEdit > + (((TextEdit) range newText) > + (pcase-let ((`(,beg . ,end) > (eglot-range-region range))) > (delete-region beg end) > (goto-char beg) > - (funcall (or snippet-fn #'insert) newText)))) > + (funcall (or snippet-fn #'insert) newText))) > + (((InsertReplaceEdit) newText replace) > + (pcase-let ((`(,beg . ,end) > + (eglot-range-region replace))) > + (delete-region beg end) > + (goto-char beg) > + (funcall (or snippet-fn #'insert) newText))))) > (snippet-fn > ;; A snippet should be inserted, but using plain > ;; `insertText'. This requires us to delete the > @@ -3602,8 +3611,12 @@ eglot--apply-text-edits > (replace-buffer-contents temp))) > (when reporter > (eglot--reporter-update reporter (cl-incf done)))))))) > - (mapcar (eglot--lambda ((TextEdit) range newText) > - (cons newText (eglot-range-region range 'markers))) > + (mapcar (lambda (text-edit-or-insert-replace-edit) > + (eglot--dcase text-edit-or-insert-replace-edit > + (((TextEdit) range newText) > + (cons newText (eglot-range-region range 'markers))) > + (((InsertReplaceEdit) newText replace) > + (cons newText (eglot-range-region replace 'markers))))) > (reverse edits))) > (undo-amalgamate-change-group change-group) > (when reporter > -- > 2.46.0.windows.1 >
bug-gnu-emacs@HIDDEN
:bug#73857
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 18 Oct 2024 00:55:19 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 17 20:55:19 2024 Received: from localhost ([127.0.0.1]:36393 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1t1bGx-0006fe-48 for submit <at> debbugs.gnu.org; Thu, 17 Oct 2024 20:55:19 -0400 Received: from lists.gnu.org ([209.51.188.17]:57418) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <kcbanner@HIDDEN>) id 1t1bGv-0006fU-7h for submit <at> debbugs.gnu.org; Thu, 17 Oct 2024 20:55:18 -0400 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 <kcbanner@HIDDEN>) id 1t1bGZ-0004sL-A1 for bug-gnu-emacs@HIDDEN; Thu, 17 Oct 2024 20:54:55 -0400 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <kcbanner@HIDDEN>) id 1t1bGX-0001n9-FR for bug-gnu-emacs@HIDDEN; Thu, 17 Oct 2024 20:54:55 -0400 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-71e4fa3ea7cso1302930b3a.0 for <bug-gnu-emacs@HIDDEN>; Thu, 17 Oct 2024 17:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729212890; x=1729817690; darn=gnu.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=nmrtCtoYcU6H5zzmSJDxiS2YeWtesgGZSkOG+Ovdyek=; b=WxUKs51Pl+vj8AjIzgfUv6exle+TAIB9Gr3Pw2OU6RjwfP94S7pjyjkkQZ0f2Ck88L vZsZAdZqj9Ev43zgJvmkG+jC3ja5HOgsLYSZJfISd0c/GamugY2AeBEaly5NH1FsqzO3 rsJ5/C0x3Kuv2QSOX5MDZ4Orx3WYxgonNKF2od8582NBFVgpCz65TO0sHD4xhPIP/pMV zRdi5XBDlVcXNxBFeEmY39iXH1cVGE05nOxWkeHyefrTvZu3NiRDC5Mo510mZ7UNTk84 6SZ7h+UvOYaIsi0CFC1MbwEaj74bhOhu9xjqELuUPJgMF/UKIOZv9GHfAplbhmHy7Xtm Vz6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729212890; x=1729817690; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=nmrtCtoYcU6H5zzmSJDxiS2YeWtesgGZSkOG+Ovdyek=; b=QQwlrHjwSRZ3sopZqFGYASxYdXs4FcIGZwtz05yoIWrnK5vQcEDlco5ydPWG7Vy+4e nh/4bNJbruX6Xby2v6c+U6ZyR3pXFLJeYJ8ihmRiaR0fo9ZIhVDz+ltPBGhOUIR+vUU9 x4tTqF9U+zSm7P/aObos2hntjX/FtLA6Db6AvmUitnLo8g0XqTGjiR62kU64tE9VqMCl 8jBX0Aw1ABFznnItCQjMGU5UhvAQY9Y7KsoXez3SMBAqJVLOZ+bW/0Ie/999qLB2DRyj iEW82gmyJNqZUS63euoE9nYxCN2jQ1VQTTatDWl9ANBsvVWjuX4le21bg6PInROrHYX3 WIqg== X-Gm-Message-State: AOJu0YzlgiZgO5rum6Erm+9MNjTcmVzDlJERHlYz9GBa56VG+k0xzvQ+ tLdbLAIMJ+XJBwv903NTMt/SjmYXpeRF2KtTi/ggJj9h6+8MIoZDEmblqNkD4Ed5uWTxI3IMqY1 lDbETq6UQwT1Wzfhb4dzMirlqfz5AVM6tcH/Mbg== X-Google-Smtp-Source: AGHT+IGdzXJllvmuzhn4y5I+V30FibE3kLJ/H0ItF78Y9jIUSn406wSveeV0t68WDSnpku36TGP6F0tEWaTajyNHjm8= X-Received: by 2002:a05:6a00:1492:b0:71e:c0c:5996 with SMTP id d2e1a72fcca58-71ea31dcc58mr1416088b3a.7.1729212889657; Thu, 17 Oct 2024 17:54:49 -0700 (PDT) MIME-Version: 1.0 From: Casey Banner <kcbanner@HIDDEN> Date: Thu, 17 Oct 2024 20:54:38 -0400 Message-ID: <CAKHgf3D4F_OBQaDqZ_cDFCzEUXNqQFPUXbTDxDVQgJ0e=viNTQ@HIDDEN> Subject: [PATCH] * lisp/progmodes/eglot.el: add support for insertReplaceEdit To: bug-gnu-emacs@HIDDEN Content-Type: multipart/mixed; boundary="000000000000079ce50624b5c03a" Received-SPF: pass client-ip=2607:f8b0:4864:20::431; envelope-from=kcbanner@HIDDEN; helo=mail-pf1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.3 (--) --000000000000079ce50624b5c03a Content-Type: multipart/alternative; boundary="000000000000079ce20624b5c038" --000000000000079ce20624b5c038 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Since 3.16, LSP supports the capability `insertReplaceSupport`. This allows textEdit to be an `InsertReplaceEdit` see: ( https://microsoft.github.io/language-server-protocol/specifications/lsp/3.1= 7/specification/#insertReplaceEdit ) This patch adds support for this capability, and uses the `replace` field of the `InsertReplaceEdit`. Original functionality (ie. `TextEdit`) is preserved. The benefits of this were originally discussed here: https://github.com/joaotavora/eglot/discussions/1456, but this is a summary= : Consider this file: ``` const Foo =3D struct { correct_name: u32, }; fn example(foo: Foo) u32 { return foo.correct_name; } ``` 1. Place the cursor on 6:22 (the _ in correct_name) 2. Backspace once to delete the t 3. Receive the following LSP message: `<-- textDocument/completion[20] {"jsonrpc":"2.0","id":20,"result":{"isIncomplete":false,"items":[{"label":"= correct_name","kind":5,"detail":"u32","documentation":{"kind":"plaintext","= value":""},"sortText":"2_correct_name","textEdit":{"range":{"start":{"line"= :5,"character":15},"end":{"line":5,"character":21}},"newText":"correct_name= "}}]}}` 4. Accept the completion 5. The buffer now contains ` return foo.correct_name_name;` on line 6 I expected it to replace the entire token, resulting in ` return foo.correct_name;`. Indeed with this patch applied (and an LSP that supports the capability), the behaviour I expected is now what happens. This is the first real elisp that I've written besides configuration, so I'm not sure if this is the correct way, but it seems to work for me. Patch is attached. Thanks! Casey In GNU Emacs 30.0.91 (build 1, x86_64-w64-mingw32) of 2024-10-17 built on DESKTOP-EK25TL1 Repository revision: 50620e96d763bd21854a95c580b572687eebc319 Repository branch: eglot_insert_replace_edit Windowing system distributor 'Microsoft Corp.', version 10.0.19045 System Description: Microsoft Windows 10 Pro (v10.0.2009.19045.5011) Configured using: 'configure -prefix=3D/e/dev/emacs-src --without-dbus --without-pop --with-native-compilation --with-xml2 --with-wide-int --without-compress-install 'CFLAGS=3D-O2 -mtune=3Dnative -march=3Dnative -fomit-frame-pointer -ftree-vectorize' PKG_CONFIG_PATH=3D/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig' --000000000000079ce20624b5c038 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Since 3.16, LSP supports the capability `insertReplaceSupp= ort`. This<br>allows textEdit to be an `InsertReplaceEdit` see:<br>(<a href= =3D"https://microsoft.github.io/language-server-protocol/specifications/lsp= /3.17/specification/#insertReplaceEdit">https://microsoft.github.io/languag= e-server-protocol/specifications/lsp/3.17/specification/#insertReplaceEdit<= /a>)<br><br>This patch adds support for this capability, and uses the `repl= ace`<br>field of the `InsertReplaceEdit`. Original functionality (ie.<br>`T= extEdit`) is preserved.<br><br>The benefits of this were originally discuss= ed here:<br><a href=3D"https://github.com/joaotavora/eglot/discussions/1456= ">https://github.com/joaotavora/eglot/discussions/1456</a>, but this is a s= ummary:<br><br>Consider this file:<br><br>```<br>const Foo =3D struct {<br>= =C2=A0 =C2=A0 correct_name: u32,<br>};<br><br>fn example(foo: Foo) u32 {<br= >=C2=A0 =C2=A0 return foo.correct_name;<br>}<br>```<br><br>1. Place the cur= sor on 6:22 (the _ in correct_name)<br>2. Backspace once to delete the t<br= >3. Receive the following LSP message: `<-- textDocument/completion[20] = {"jsonrpc":"2.0","id":20,"result":{= "isIncomplete":false,"items":[{"label":"= correct_name","kind":5,"detail":"u32",&q= uot;documentation":{"kind":"plaintext","value= ":""},"sortText":"2_correct_name","= textEdit":{"range":{"start":{"line":5,&q= uot;character":15},"end":{"line":5,"character= ":21}},"newText":"correct_name"}}]}}`<br>4. Accept= the completion<br>5. The buffer now contains ` =C2=A0 =C2=A0return foo.cor= rect_name_name;` on line 6<br><br>I expected it to replace the entire token= , resulting in ` =C2=A0 =C2=A0return foo.correct_name;`.<br><br>Indeed with= this patch applied (and an LSP that supports the<br>capability), the behav= iour I expected is now what happens.<br><br>This is the first real elisp th= at I've written besides configuration, so<br><div>I'm not sure if t= his is the correct way, but it seems to work for me.</div><div><br></div><d= iv>Patch is attached.<br></div><div><br></div>Thanks!<br>Casey<br><br><br>I= n GNU Emacs 30.0.91 (build 1, x86_64-w64-mingw32) of 2024-10-17 built<br>= =C2=A0on DESKTOP-EK25TL1<br>Repository revision: 50620e96d763bd21854a95c580= b572687eebc319<br>Repository branch: eglot_insert_replace_edit<br>Windowing= system distributor 'Microsoft Corp.', version 10.0.19045<br>System= Description: Microsoft Windows 10 Pro (v10.0.2009.19045.5011)<br><br>Confi= gured using:<br>=C2=A0'configure -prefix=3D/e/dev/emacs-src --without-d= bus --without-pop<br>=C2=A0--with-native-compilation --with-xml2 --with-wid= e-int<br>=C2=A0--without-compress-install 'CFLAGS=3D-O2 -mtune=3Dnative= -march=3Dnative<br>=C2=A0-fomit-frame-pointer -ftree-vectorize'<br>=C2= =A0PKG_CONFIG_PATH=3D/mingw64/lib/pkgconfig:/mingw64/share/pkgconfig'<b= r></div> --000000000000079ce20624b5c038-- --000000000000079ce50624b5c03a Content-Type: application/octet-stream; name="0001-lisp-progmodes-eglot.el-add-support-for-insertReplac.patch" Content-Disposition: attachment; filename="0001-lisp-progmodes-eglot.el-add-support-for-insertReplac.patch" Content-Transfer-Encoding: base64 Content-ID: <f_m2e0on3y0> X-Attachment-Id: f_m2e0on3y0 RnJvbSBiYmY3OWY5NTYzNmQ2OTljY2Y5YmE3MDI4ZTZjM2RjZTIzYWYyMzc4IE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBrY2Jhbm5lciA8a2NiYW5uZXJAZ21haWwuY29tPgpEYXRlOiBU aHUsIDE3IE9jdCAyMDI0IDAwOjQzOjMyIC0wNDAwClN1YmplY3Q6IFtQQVRDSF0gKiBsaXNwL3By b2dtb2Rlcy9lZ2xvdC5lbDogYWRkIHN1cHBvcnQgZm9yIGluc2VydFJlcGxhY2VFZGl0CgotLS0K IGxpc3AvcHJvZ21vZGVzL2VnbG90LmVsIHwgMjUgKysrKysrKysrKysrKysrKysrKy0tLS0tLQog MSBmaWxlIGNoYW5nZWQsIDE5IGluc2VydGlvbnMoKyksIDYgZGVsZXRpb25zKC0pCgpkaWZmIC0t Z2l0IGEvbGlzcC9wcm9nbW9kZXMvZWdsb3QuZWwgYi9saXNwL3Byb2dtb2Rlcy9lZ2xvdC5lbApp bmRleCAwYTE0MTQ2YTI0NS4uODI4NTUwNjkyOGYgMTAwNjQ0Ci0tLSBhL2xpc3AvcHJvZ21vZGVz L2VnbG90LmVsCisrKyBiL2xpc3AvcHJvZ21vZGVzL2VnbG90LmVsCkBAIC02NDcsNiArNjQ3LDcg QEAgZWdsb3QtLXVyaS1wYXRoLWFsbG93ZWQtY2hhcnMKICAgICAgICAgICAgICAgICAgICAgICAo OmRldGFpbCA6ZGVwcmVjYXRlZCA6Y2hpbGRyZW4pKQogICAgICAgKFRleHREb2N1bWVudEVkaXQg KDp0ZXh0RG9jdW1lbnQgOmVkaXRzKSAoKSkKICAgICAgIChUZXh0RWRpdCAoOnJhbmdlIDpuZXdU ZXh0KSkKKyAgICAgIChJbnNlcnRSZXBsYWNlRWRpdCAoOm5ld1RleHQgOmluc2VydCA6cmVwbGFj ZSkpCiAgICAgICAoVmVyc2lvbmVkVGV4dERvY3VtZW50SWRlbnRpZmllciAoOnVyaSA6dmVyc2lv bikgKCkpCiAgICAgICAoV29ya0RvbmVQcm9ncmVzcyAoOmtpbmQpICg6dGl0bGUgOm1lc3NhZ2Ug OnBlcmNlbnRhZ2UgOmNhbmNlbGxhYmxlKSkKICAgICAgIChXb3Jrc3BhY2VFZGl0ICgpICg6Y2hh bmdlcyA6ZG9jdW1lbnRDaGFuZ2VzKSkKQEAgLTk1OSw3ICs5NjAsOCBAQCBlZ2xvdC1jbGllbnQt Y2FwYWJpbGl0aWVzCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgWyJkb2N1bWVudGF0aW9uIgogICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAiZGV0YWlscyIKICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgImFkZGl0aW9uYWxUZXh0RWRp dHMiXSkKLSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOnRhZ1N1cHBvcnQg KDp2YWx1ZVNldCBbMV0pKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6 dGFnU3VwcG9ydCAoOnZhbHVlU2V0IFsxXSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgOmluc2VydFJlcGxhY2VTdXBwb3J0IHQpCiAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICA6Y29udGV4dFN1cHBvcnQgdCkKICAgICAgICAgICAgICA6aG92ZXIgICAg ICAgICAgICAgIChsaXN0IDpkeW5hbWljUmVnaXN0cmF0aW9uIDpqc29uLWZhbHNlCiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA6Y29udGVudEZvcm1hdCAoZWdsb3QtLWFj Y2VwdGVkLWZvcm1hdHMpKQpAQCAtMzM2OCwxMiArMzM3MCwxOSBAQCBlZ2xvdC1jb21wbGV0aW9u LWF0LXBvaW50CiAgICAgICAgICAgICAgICAgICAgICAgICA7OyBzdGF0ZSwgX25vdF8gdGhlIGN1 cnJlbnQgImZvby5iYXIiLgogICAgICAgICAgICAgICAgICAgICAgICAgKGRlbGV0ZS1yZWdpb24g b3JpZy1wb3MgKHBvaW50KSkKICAgICAgICAgICAgICAgICAgICAgICAgIChpbnNlcnQgKHN1YnN0 cmluZyBib3VuZHMtc3RyaW5nICgtIG9yaWctcG9zIChjYXIgYm91bmRzKSkpKQotICAgICAgICAg ICAgICAgICAgICAgICAgKGVnbG90LS1kYmluZCAoKFRleHRFZGl0KSByYW5nZSBuZXdUZXh0KSB0 ZXh0RWRpdAotICAgICAgICAgICAgICAgICAgICAgICAgICAocGNhc2UtbGV0ICgoYCgsYmVnIC4g LGVuZCkKKyAgICAgICAgICAgICAgICAgICAgICAgIChlZ2xvdC0tZGNhc2UgdGV4dEVkaXQKKyAg ICAgICAgICAgICAgICAgICAgICAgICAgKCgoVGV4dEVkaXQpIHJhbmdlIG5ld1RleHQpCisgICAg ICAgICAgICAgICAgICAgICAgICAgICAocGNhc2UtbGV0ICgoYCgsYmVnIC4gLGVuZCkKICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIChlZ2xvdC1yYW5nZS1yZWdpb24gcmFu Z2UpKSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZGVsZXRlLXJlZ2lvbiBiZWcgZW5k KQogICAgICAgICAgICAgICAgICAgICAgICAgICAgIChnb3RvLWNoYXIgYmVnKQotICAgICAgICAg ICAgICAgICAgICAgICAgICAgIChmdW5jYWxsIChvciBzbmlwcGV0LWZuICMnaW5zZXJ0KSBuZXdU ZXh0KSkpKQorICAgICAgICAgICAgICAgICAgICAgICAgICAgIChmdW5jYWxsIChvciBzbmlwcGV0 LWZuICMnaW5zZXJ0KSBuZXdUZXh0KSkpCisgICAgICAgICAgICAgICAgICAgICAgICAgICgoKElu c2VydFJlcGxhY2VFZGl0KSBuZXdUZXh0IHJlcGxhY2UpCisgICAgICAgICAgICAgICAgICAgICAg ICAgICAocGNhc2UtbGV0ICgoYCgsYmVnIC4gLGVuZCkKKyAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAoZWdsb3QtcmFuZ2UtcmVnaW9uIHJlcGxhY2UpKSkKKyAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgKGRlbGV0ZS1yZWdpb24gYmVnIGVuZCkKKyAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgKGdvdG8tY2hhciBiZWcpCisgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIChmdW5jYWxsIChvciBzbmlwcGV0LWZuICMnaW5zZXJ0KSBuZXdUZXh0KSkpKSkKICAg ICAgICAgICAgICAgICAgICAgICAgKHNuaXBwZXQtZm4KICAgICAgICAgICAgICAgICAgICAgICAg IDs7IEEgc25pcHBldCBzaG91bGQgYmUgaW5zZXJ0ZWQsIGJ1dCB1c2luZyBwbGFpbgogICAgICAg ICAgICAgICAgICAgICAgICAgOzsgYGluc2VydFRleHQnLiAgVGhpcyByZXF1aXJlcyB1cyB0byBk ZWxldGUgdGhlCkBAIC0zNjAyLDggKzM2MTEsMTIgQEAgZWdsb3QtLWFwcGx5LXRleHQtZWRpdHMK ICAgICAgICAgICAgICAgICAgICAgICAgICAgKHJlcGxhY2UtYnVmZmVyLWNvbnRlbnRzIHRlbXAp KSkKICAgICAgICAgICAgICAgICAgICAgICAod2hlbiByZXBvcnRlcgogICAgICAgICAgICAgICAg ICAgICAgICAgKGVnbG90LS1yZXBvcnRlci11cGRhdGUgcmVwb3J0ZXIgKGNsLWluY2YgZG9uZSkp KSkpKSkpCi0gICAgICAgICAgICAobWFwY2FyIChlZ2xvdC0tbGFtYmRhICgoVGV4dEVkaXQpIHJh bmdlIG5ld1RleHQpCi0gICAgICAgICAgICAgICAgICAgICAgKGNvbnMgbmV3VGV4dCAoZWdsb3Qt cmFuZ2UtcmVnaW9uIHJhbmdlICdtYXJrZXJzKSkpCisgICAgICAgICAgICAobWFwY2FyIChsYW1i ZGEgKHRleHQtZWRpdC1vci1pbnNlcnQtcmVwbGFjZS1lZGl0KQorICAgICAgICAgICAgICAgICAg ICAgIChlZ2xvdC0tZGNhc2UgdGV4dC1lZGl0LW9yLWluc2VydC1yZXBsYWNlLWVkaXQKKyAgICAg ICAgICAgICAgICAgICAgICAgICgoKFRleHRFZGl0KSByYW5nZSBuZXdUZXh0KQorICAgICAgICAg ICAgICAgICAgICAgICAgIChjb25zIG5ld1RleHQgKGVnbG90LXJhbmdlLXJlZ2lvbiByYW5nZSAn bWFya2VycykpKQorICAgICAgICAgICAgICAgICAgICAgICAgKCgoSW5zZXJ0UmVwbGFjZUVkaXQp IG5ld1RleHQgcmVwbGFjZSkKKyAgICAgICAgICAgICAgICAgICAgICAgICAoY29ucyBuZXdUZXh0 IChlZ2xvdC1yYW5nZS1yZWdpb24gcmVwbGFjZSAnbWFya2VycykpKSkpCiAgICAgICAgICAgICAg ICAgICAgIChyZXZlcnNlIGVkaXRzKSkpCiAgICAgICAodW5kby1hbWFsZ2FtYXRlLWNoYW5nZS1n cm91cCBjaGFuZ2UtZ3JvdXApCiAgICAgICAod2hlbiByZXBvcnRlcgotLSAKMi40Ni4wLndpbmRv d3MuMQoK --000000000000079ce50624b5c03a--
Casey Banner <kcbanner@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#73857
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.