From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#66552: 30.0.50; Eglot feature request: handle quirky code actions Date: Tue, 17 Oct 2023 22:38:46 +0100 Message-ID: References: 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="1565"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66552@debbugs.gnu.org To: Richard Copley Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 17 23:39:49 2023 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 1qsrn2-0000C8-G8 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 17 Oct 2023 23:39:48 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qsrms-00005X-Kq; Tue, 17 Oct 2023 17:39:38 -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 1qsrmr-0008Q8-1p for bug-gnu-emacs@gnu.org; Tue, 17 Oct 2023 17:39:37 -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 1qsrmq-00054t-PN for bug-gnu-emacs@gnu.org; Tue, 17 Oct 2023 17:39:36 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qsrnF-00055L-UQ for bug-gnu-emacs@gnu.org; Tue, 17 Oct 2023 17:40:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 17 Oct 2023 21:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66552 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 66552-submit@debbugs.gnu.org id=B66552.169757877219498 (code B ref 66552); Tue, 17 Oct 2023 21:40:01 +0000 Original-Received: (at 66552) by debbugs.gnu.org; 17 Oct 2023 21:39:32 +0000 Original-Received: from localhost ([127.0.0.1]:32906 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qsrmm-00054Q-6X for submit@debbugs.gnu.org; Tue, 17 Oct 2023 17:39:32 -0400 Original-Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]:46426) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qsrmk-000546-0E for 66552@debbugs.gnu.org; Tue, 17 Oct 2023 17:39:30 -0400 Original-Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2c50305c5c4so73285661fa.1 for <66552@debbugs.gnu.org>; Tue, 17 Oct 2023 14:39:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697578738; x=1698183538; 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=zLC52mst2ACqC+u7TRkoKmpya7RFXuedZIcZdg6XRDs=; b=H/fBiMN9aikhgJdAYr125IO6Ox1NwC1q4RPBCwMWMSn/XBBttVj7xoNJlTnimiUpci qjgwQqf7Fdy5mBLu3LgbQAHbl4+iZ39GL2O7A4vxsJg2QBE13SUqcrmj2DqPO81VqO8l SujFb+MORXsyprtX1GvbPD9DVEcisq0Q600yDG8DSqDfULkofcYsyZ8vtyToibhOZsBW Sy8giPbwnOyCkb0zwN/MSNozTgq8Pc/WMI6Szk1R8eSbP+XxmV6Ox5OjvwkYc+n0q58v 0zgjzX5wDjypnmq6opfLk+yvqaPmCI0s7Ci9DAPtIpPS4g8Crk05QJjZhQv+g9/eFGx3 gI4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697578738; x=1698183538; 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=zLC52mst2ACqC+u7TRkoKmpya7RFXuedZIcZdg6XRDs=; b=XxNy9zLMBGSTt6u/tDkI9khC0akOUg3vtdmKC7WqUhDY9s04/7MLgvXomOkgkyAShn 2zPJXlD8LGYkG1/8+EkQeAdoprt1wbo5t1KYoTlwgGg49cKQw6enG9k4H+JK1ob3MCw/ 00pFsamvjpPbSEPgk8nvvBzXxytLDHaFxdyO+aPiDIFcFhajpSAaJ1LRMTudPBapFaC+ r8tgzw43nt3DHsLny+XiQ+8MM41sqRXr4OoP27O/oPovJbu8l34a2hNPiZXn71vTslnm 8d72pj2r8BsinzF8Ww06Ce8UBtSEGTur8tBhYb6KxzKGUWJtQ52dPnzE8NKH5M4f47H1 0gOg== X-Gm-Message-State: AOJu0Yy3uLOUfjHfvwIY68i5kI7eeEOtGjp5BfqORqjifkiKETbN8bk1 lMxhyNfLPb1L+sRKj00wVWGVae7qJU/eEouOLaE= X-Google-Smtp-Source: AGHT+IGm9Y56gx/6DZZHAgaaM9GbzFaV+1xans/Wjbsf9TxANCNo/PPsqQ1Xb6eF8PW56a8X0+BI5PmlENL/Kdq4lAI= X-Received: by 2002:a05:651c:2222:b0:2c5:a21:8388 with SMTP id y34-20020a05651c222200b002c50a218388mr3101341ljq.29.1697578738021; Tue, 17 Oct 2023 14:38:58 -0700 (PDT) In-Reply-To: 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:272639 Archived-At: On Tue, Oct 17, 2023 at 8:08=E2=80=AFPM Richard Copley = wrote: > > If a servers sends no field, Eglot will > > ignore it. If it sends a wrong one, Eglot won't. > > > You could work around it with a monkey-patch by advising > > eglot--apply-text-edits to always have a null second argument. > > I'll probably go with that. Thanks for the suggestion. It's a shame > that this will affect all languages. It would be nice if I could use a > defmethod dispatching on a subclass of eglot-lsp-server! But > eglot--apply-text-edits doesn't take a server, so it isn't generic. For eglot--apply-text-edits to become a generic, it would first have to be promoted to Eglot's user API (losing the --), and I don't see a very good reason to do that right now. However, if you wanted a fully "legal" solution, I think you could place a server-specific method on eglot-handle-request (server your-server) (method workspace/applyEdit) which removes or massages the `version` cookie in the `edit` keyword argument. And even with the monkey-patching approach, you can make something server specific by checking the return value of `eglot-current-server` before tweaking the value. Another possibility is for Eglot to start interpreting version 0 as "any version". It should be feasible since Eglot controls the start of the numbering, which right now is 0 but be increased to 1, hopefully without any negative consequences. > > The second labeling problem is even more bizarre Again, you > > can probably monkey-patch Eglot to work around it. > > Here I'm not sure I agree. The title is only specified to be "A short, > human-readable, title for this code action". In this case the > suggestions are computed, and inventing unique friendly names for them > isn't feasible. "Apply 'Try this'" seems sensible. It refers to the > text of the corresponding diagnostic, "Try this : ". This newText is hidden deep inside the `edits` field of such messages. There's no guarantee it's a 1-element array or even that the edit is just an insertion. So grabbing it consistently to craft a user-visible message is just a bad idea It doesn't make sense for a language server to provide a bunch of actions with identical labels. It isn't something the client should have to deal with. A label, to me, is a piece of information for telling one object apart from another object. If the text of the corresponding diagnostic is (presumably unique), why can't the label be unique as well? Jo=C3=A3o