Subject: Re: bug#67470: 29.1; move-end-of-line behaves badly with eglot type annotations

From: João Távora <[email-masked]>
Date: Mon, 27 Nov 2023 13:02:36 +0000

On Mon, Nov 27, 2023 at 12:35 PM Eli Zaretskii <[email-masked]> wrote:
>
> > From: [email-masked]
> > Date: Sun, 26 Nov 2023 23:37:04 +0000
> >
> >
> > 1. Go to a buffer with some code
> > 2. Start eglot
> > 3. Eglot adds type annotations
> > 4. Go to some line that ends with a type annotation
> > 5. Press C-e to go to the end of the line
> > 6. Navigate around with C-n and C-p
> > 7. Note that point will jump to the column of the position of the end of
> > the type annotation, rather than the end of the code.
> >
> > For instance, if you have some code and some annotations (represented
> > with a) like so, with point at |:
> >
> > some|code aaaaaaaaaa
> > here are some more lines which do not have annotations
> >
> > Pressing C-e will move point to the end of the line
> >
> > some cod| aaaaaaaaaa
> > here are some more lines which do not have annotations
> >
> > Then when you press C-n, instead of point moving to the same column in
> > the next line, like so:
> >
> > some code aaaaaaaaaa
> > here are|some more lines which do not have annotations
> >
> > It will instead jump to the column of the end of the annotation, like
> > so:
> >
> > some code aaaaaaaaaa
> > here are some more |ines which do not have annotations

some code aaaaaaaaaa
> > here are|some more lines which do not have annotations

Hi Eli,

I have reproduced this.  I can even add the following curious example

  some code aaaaaaaaaa
  here are|some more lines which do not have annotations

Press C-p, get

  some cod| aaaaaaaaaa
  here are some more lines which do not have annotations

Which looks like just what you would get if you had pressed C-e
in the first line.  Now type C-n.

  some code aaaaaaaaaa
  here are|some more lines which do not have annotations

Which is exactly what you expect.  So, the manner in which
one arrives at the end of the line matters.

> João, how are those annotations shown?

With 'before-string' and 'after-string' properties, as you
guessed.

For example, here's a snippet of awkward but valid C++ code, where I
include the annotation:

auto bla: int
    = 42; heyheyheyheyhey

The ": int" 5-character string is the value of the before-string
property of the 1-char-long overlay that spans the newline character
separating the two lines.

> I cannot run Eglot on my
> system to try this recipe, but if I just put an overlay with a before-
> or after-string at the end of a line, C-e moves to after the overlay
> string, not before it.  Does Eglot do anything to change that?

Yes, it sets the property "cursor" to 1 in the first character of the
5-character string. This is intentionally done so that, among other reasons,
if you C-e to the end, you can edit the the 'bla' identifier without the
awkwardness of typing characters after the annotation and seeing them
pop into place after some time.

> cursor movement in the presence of overlay strings, and can only be
> changed if Eglot had its own commands for C-n/C-p, which set
> goal-column or something before moving.

Eglot does not change these commands.

João