Subject: bug#22098: 25.0.50; visual-line-mode and invisible text causes cursor to jump

From: Ian Dunn <[email-masked]>
Date: Tue, 08 Dec 2015 20:33:39 -0500

Eli Zaretskii <[email-masked]> writes:

>> I try not to assume that everyone has the same key-bindings as me, so I
>> thought it might help to use the actual command names.
>
> Yes, but you should be aware that this might make a difference for
> redisplay problems: typing M-x causes a mildly thorough redisplay, so
> it might obscure some problems and cause some others.  That's why I
> asked.
>

I did not know that.  Thanks for the tip.

> Anyway, I fixed the problem I see here in commit cca5629 on the
> emacs-25 branch.  Please see if your problem is solved by that change.
>
> Thanks.

Thanks once again for the quick response, and my apologies for my
sluggish response.

That fixed the problem in that sample I gave to you, but I noticed a
similar problem that I just figured out how to replicate:

  emacs -Q output.txt
  visual-line-mode
  global-hl-line-mode
  M-g M-g 19
  C-p
  C-M-: (add-text-properties (point) (1+ (point)) '(invisible t))
  C-p
  C-l C-l
  C-n C-n
  C-p

What I see happen is point jump to exactly half-way down the window.
This only seems to happen when the invisible text is on the second
visual line of the window, but the start of the line isn't the first.

To demonstrate this, here is what I see when I encounter the bug:

words are formatted and printed--emacs outshines all other editing software in approximately the same
way that the noonday sun does the stars. It is not just bigger and brighter; it simply makes
everything else vanish.

I make the 'w' in "way" invisible (since making the 'e' in "everything"
invisible causes that word to jump to the previous visual line), and
re-position the window such that "words" is the first visible word in
the window (So those three lines are the first three visual lines of the
window).  Then, I move point down two visual lines, and then try to move
it back up so it is over the word "ay" (way with an invisible "w").
When I do, the cursor (and I assume point) immediately jumps to one line
above the middle of the window.  I verified this last bit by moving the
cursor in an adjacent window to the exact center, and comparing.  The
cursor in the first window appears to be exactly one line above center.

Also, it only happens when global-hl-line-mode is also active.

If the involvement of global-hl-line-mode in this constitutes a separate
bug, then just let me know so I can file another report.

I updated output.txt with with additional (actual) text, so to verify
that we are in fact using the same file, I've attached it again.

Once again, thank you for your help.

Ian Dunn