Subject: bug#45319: 28.0.50; Redisplay: `forward-char' moves backwards into invisible text

From: Eli Zaretskii <[email-masked]>
Date: Sat, 19 Dec 2020 11:10:48 +0200

> From: Michael Heerdegen <[email-masked]>
> Date: Sat, 19 Dec 2020 07:10:53 +0100
> Cc: Jonas Bernoulli <[email-masked]>
> 
>   (defvar my-magit-log-show-only-hash-lines-mode-keywords
>     `((,(rx (and bol space (* any) eol))
>        (0 (let ((beg (match-beginning 0))
>                 (end (1+ (match-end 0))))
>             (add-text-properties beg end
>                                  (list 'invisible 'my-magit-log-show-only-hash-lines))
>             nil)))))
> 
>   (define-minor-mode my-magit-log-show-only-hash-lines-mode
>     "..." nil nil nil
>     (if (not my-magit-log-show-only-hash-lines-mode)
>         (remove-from-invisibility-spec 'my-magit-log-show-only-hash-lines)
>       (font-lock-add-keywords nil my-magit-log-show-only-hash-lines-mode-keywords)
>       (add-to-invisibility-spec 'my-magit-log-show-only-hash-lines)))
> 
> Now enable that mode in the buffer and M-x font-lock-fontify-buffer.
> 
> When I now move around in the buffer with the arrow keys, it often
> happens that when point is at the beginning of a visible line, and I hit
> <right>, the echo area shows that point actually has moved backwards into
> the invisible area somewhere before that line, but the cursor is placed
> at the expected position.  Further movement behaves as expected from the
> drawn cursor position, just the value of `point' sometimes is
> inconsistent, and that can cause trouble (like incorrect section
> highlighting in the Magit Log buffer).

Does setting global-disable-point-adjustment non-nil and repeating
your experiment explain what happens?

It isn't a redisplay problem.