Subject: Re: bug#54946: 28.1; next-line skip one line when overlay is added in newline

From: Eli Zaretskii <[email-masked]>
Date: Fri, 15 Apr 2022 12:08:07 +0300

> From: Yikai Zhao <[email-masked]>
> Date: Fri, 15 Apr 2022 10:25:50 +0800
> 
> I encountered this issue when I'm editing some code using flycheck-mode
> and evil-mode: after flycheck-mode added an error region at the end of
> the line, press <down> on this line should forward two lines instead of
> one.
> 
> Here's the recipe to reproduce it using 'emacs -Q':
> 
> 
>     (with-current-buffer (get-buffer-create "test")
>       (setq truncate-lines t
>             line-move-visual nil)
>       (erase-buffer)
>       (insert (make-string 1000 ?x) "\nHELLO\nWORLD\n")
>       (let ((ov (make-overlay 1001 1002)))
>         (overlay-put ov 'before-string
>                      (propertize "!" 'display '(left-fringe right-arrow error))))
>       (beginning-of-buffer)
>       (switch-to-buffer (current-buffer)))
> 
> After executing the code, press <down>, the cursor would move to line 3;
> but I think the expected behavior is that the cursor would move to line 2.

Thanks.  This is a very old bug, and rears its ugly head only of
line-move-visual is disabled.

Should be fixed now on the emacs-28 branch.