Subject: Re: bug#72597: 30.0.60; Eglot: MarkedString with embedded Carriage Return

From: João Távora <[email-masked]>
Date: Fri, 6 Sep 2024 20:31:08 +0100

On Fri, Sep 6, 2024 at 6:44 AM Eli Zaretskii <[email-masked]> wrote:
>
> > From: Daniel Pettersson <[email-masked]>
> > Cc: Eli Zaretskii <[email-masked]>,  Troy Brown <[email-masked]>,
> >   [email-masked],  [email-masked]
> > Date: Thu, 05 Sep 2024 23:32:08 +0200
> >
> > > Anyway, if the solution is to be performed at this lower
> > > level (which I think it should), then Daniel Petterson
> > > jsonrpc.el maintainer should be added.
> >
> > I might be missing something, but jsonrpc should not in my mind
> > convert/format/encode any json data.  Any assumptions on line endings
> > can only be made on header and content separators, not on the json
> > payload itself.
>
> That depends on the reason why the CR character appeared there in the
> first place.  Are they required for the strings in questions, or are
> they simply an artifact of how the server marshaled JSON data on the
> wire?

Indeed this is the question.  And it is not necessarily easy to asnwer.
For example most LSP servers may be used to edit CRLF terminated
files, and when doing so they will possibly exchange file snippets with
intentional CR chars in them (however odd that may be for most
people, it can happen).  But that is theoretically completely independent
of the decision to terminate documentation snippets with CRLF or just
LF or just CR.  Both these kinds of snippets are transmitted as JSON
strings over the wire.  jsonrpc.el makes them Elisp strings and (afair)
doesn't do any newline conversion.

Even if Eglot is most well positioned to answer this question in
the LSP case, i don't think it can: there's no interface for doing so.
If it could, then it could theoretically ask jsonrpc.el to do that
conversion. But it can't.

So perhaps something like Troys patch for the "doc view" layer
is best if inefficient/hacky.  Even fixing it in gfm-view-mode isn't a bad
idea. But also, I don't think this is a very urgent matter: the server
that does this is clearly in the minority.  I would just ask this server's
devs if they wouldn't mind not sending these odd doc snippets.

João