Subject: Re: bug#79259: [PATCH] Fix arg doc off-by-one bug of eglot signature help

From: Eli Zaretskii <[email-masked]>
Date: Sat, 30 Aug 2025 11:04:47 +0300

> Cc: [email-masked]
> Date: Sun, 17 Aug 2025 06:47:38 +0800
> From:  Lin Jian via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> João Távora <[email-masked]> writes:
> 
> > Thanks, but I (or whoever) added the 1+ there probably did so for 
> > a reason.  
> 
> It was added by you[1].
> 
> > Maybe they were mistaken, but you have to supply a reproduction recipe
> > that demonstrates there's a problem with that, so we can check the 
> > before and after, else I could be fixing it for you and breaking it for
> > someone else.
> 
> I've reported some bugs and I'm familiar with (info "(emacs)Bugs").
> 
> I did not include a reproduction recipe in this report because I think
> it is trivial to reproduce:
> 
> 1. use a LSP server supporting argument documentation in the signature
> help
> 2. get one signature help with argument documentation from eglot
> 3. see the highlight of argument documentation is off-by-one
> 
> typescript-language-server is mentioned in the commit[1] adding `1+', so
> I guess it can be used for reproduction.
> 
> I am developing[2] the signature help feature for
> haskell-language-server, which causes me to discover this off-by-one
> "bug".
> 
> I added two screenshots before and after applying my patch as
> attachments.
> 
> 
> Here is the transcript between eglot and my developing
> haskell-language-server:
> 
> [jsonrpc] e[06:33:30.460] --> textDocument/signatureHelp[192] 
> (:jsonrpc "2.0" :id 192 :method "textDocument/signatureHelp" :params
>           (:textDocument
>            (:uri
>             "file:///home/linj/code/origin/hydra-scraper/src/TestHls.hs")
>            :position (:line 107 :character 19)))
> [jsonrpc] e[06:33:30.471] <-- textDocument/signatureHelp[192] 
> (:id 192 :jsonrpc "2.0" :result
>      (:activeParameter 0 :activeSignature 0 :signatures
>                        [(:activeParameter 0 :documentation
>                                           (:kind "markdown" :value
>                                                  "\n\nFun doc for  `fsimple` .\n\n")
>                                           :label
>                                           "fsimple :: forall a. a -> Bool -> Char"
>                                           :parameters
>                                           [(:documentation
>                                             (:kind "markdown" :value
>                                                    "\n\nThe first arg.\n\n")
>                                             :label [21 22])
>                                            (:documentation
>                                             (:kind "markdown" :value
>                                                    "\n\nThe second  `Bool`  arg.\n\n")
>                                             :label [26 30])])
>                         (:activeParameter 0 :documentation
>                                           (:kind "markdown" :value
>                                                  "\n\nFun doc for  `fsimple` .\n\n")
>                                           :label
>                                           "fsimple :: Integer -> Bool -> Char"
>                                           :parameters
>                                           [(:documentation
>                                             (:kind "markdown" :value
>                                                    "\n\nThe first arg.\n\n")
>                                             :label [11 18])
>                                            (:documentation
>                                             (:kind "markdown" :value
>                                                    "\n\nThe second  `Bool`  arg.\n\n")
>                                             :label [22 26])])]))
> 
> > Please see https://joaotavora.github.io/eglot/#Reporting-bugs-1 for how to 
> > report an Emacs -Q recipe (including a LSP server setup).
> 
> Thanks for the link.  I forgot to check that it before sending my
> report.
> 
> I do not have time to provide more info now.
> 
> I think the above information is probably enough for this bug.  In
> particular, the above server reply of signature help should be enough
> for reproduction.  If it is not the case, please let me know and I will
> provide more info later when I have time.

João, are you okay with the patch, given the additional information
posted by Lin Jian?