Subject: bug#74914: closed (Re: bug#74914: 30.0.90; Eglot: Incorrect parameter highlighted in signatureHelp)

From: [email-masked] (GNU bug Tracking System)
Date: Mon, 06 Jan 2025 10:56:02 +0000

Your bug report

#74914: 30.0.90; Eglot: Incorrect parameter highlighted in signatureHelp

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
74914: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74914
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#74914: 30.0.90; Eglot: Incorrect parameter highlighted in signatureHelp
From: João Távora <[email-masked]>
To: Troy Brown <[email-masked]>, [email-masked]
Cc: Dmitry Gutov <[email-masked]>, Felician Nemeth <[email-masked]>
Date: Mon, 6 Jan 2025 10:55:26 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

I pushed this patch yesterday.  Thanks everyone, closing the bug.

On Sun, Jan 5, 2025 at 2:20 AM Troy Brown <[email-masked]> wrote:
>
> On Sat, Dec 28, 2024 at 10:22 PM Dmitry Gutov <[email-masked]> wrote:
> >
> > So, does this fix the problem for you?
> >
> > diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
> > index 816a1e67eca..51c19d5681a 100644
> > --- a/lisp/progmodes/eglot.el
> > +++ b/lisp/progmodes/eglot.el
> > @@ -3416,7 +3416,7 @@ eglot--sig-info
> >                                          'font-lock-function-name-face))))
> >         ;; Now to the parameters
> >         (cl-loop
> > -       with active-param = (or sig-active activeParameter)
> > +       with active-param = (or activeParameter sig-active)
> >          for i from 0 for parameter across parameters do
> >          (eglot--dbind ((ParameterInformation)
> >                         ((:label parlabel))
> >
>
> I'm not sure how the diff was created, as I couldn't get it to apply
> cleanly, but yes, this change does fix the issue.

-- 
João Távora

Subject: 30.0.90; Eglot: Incorrect parameter highlighted in signatureHelp
From: Troy Brown <[email-masked]>
To: "simon254--- via Bug reports for GNU Emacs, the Swiss army knife of text editors" <[email-masked]>
Cc: Felician Nemeth <[email-masked]>,João Távora <[email-masked]>
Date: Mon, 16 Dec 2024 10:19:14 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

I'm working with a language server that provides an `activeParameter`
field both in SignatureHelp (set to 0) as well as in
SignatureInformation (set to 1).  Under this condition, for the
signature output in the echo area, Eglot always displays the first
parameter (i.e., index 0).  According to the LSP specification, when
an `activeParameter` field is specified in SignatureInformation "this
is used in place of `SignatureHelp.activeParameter`".  The following
is a partial log covering this transaction:

[jsonrpc] e[09:50:52.423] --> textDocument/signatureHelp[97]
{"jsonrpc":"2.0","id":97,"method":"textDocument/signatureHelp","params":{"textDocument":{"uri":"file:///home/troy/junk/gtkada_24.0.0_80c56171/src/glib.adb"},"position":{"line":102,"character":38}}}
[jsonrpc] e[09:50:52.444] <-- textDocument/publishDiagnostics
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/troy/junk/gtkada_24.0.0_80c56171/src/glib.adb","diagnostics":[{"range":{"start":{"line":102,"character":38},"end":{"line":102,"character":39}},"source":"libadalang","message":"Missing
';'"},{"range":{"start":{"line":102,"character":38},"end":{"line":102,"character":39}},"source":"libadalang","message":"Skipped
token )"},{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"severity":4,"source":"ada.project","message":""}]}}
[jsonrpc] e[09:50:52.445] <-- textDocument/hover[95]
{"jsonrpc":"2.0","id":95,"result":null}
[jsonrpc] e[09:50:52.454] <-- textDocument/documentHighlight[96]
{"jsonrpc":"2.0","id":96,"result":null}
[jsonrpc] e[09:50:52.454] <-- textDocument/signatureHelp[97]
{"jsonrpc":"2.0","id":97,"result":{"signatures":[{"label":"function
Internal (Name : String; Thing : String) return
GType","documentation":"","parameters":[{"label":"Name"},{"label":"Thing"}],"activeParameter":1}],"activeSignature":0,"activeParameter":0}}

I believe the reason for Eglot's behavior is due to the way
"active-param" is specified in the cl-loop within `eglot--sig-info`.
```text
with active-param = (or sig-active activeParameter)
```
The value of activeParameter in SignatureInformation (activeParameter)
should be given higher priority (i.e., listed first) over the
activeParameter specified in SignatureHelp (sig-active).