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

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!

In GNU Emacs 28.1 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6)
 of 2022-04-10 built on frederik
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Arch Linux

Configured using:
 'configure --with-native-compilation --without-compress-install
 --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib
 --localstatedir=/var --with-cairo --with-harfbuzz --with-modules
 --with-wide-int --with-x-toolkit=gtk3 --with-xft 'CFLAGS=-march=x86-64
 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2
 -Wformat -Werror=format-security -fstack-clash-protection
 -fcf-protection -g -ffile-prefix-map=/build/emacs/src=/usr/src/debug
 -flto=auto' 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now
 -flto=auto''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LC_CTYPE: zh_CN.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=fcitx
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  global-git-commit-mode: t
  recentf-mode: t
  dap-tooltip-mode: t
  dap-ui-many-windows-mode: t
  dap-ui-controls-mode: t
  dap-ui-mode: t
  dap-auto-configure-mode: t
  dap-mode: t
  treemacs-filewatch-mode: t
  treemacs-follow-mode: t
  treemacs-git-mode: t
  treemacs-fringe-indicator-mode: t
  ligature-mode: t
  outline-minor-mode: t
  whitespace-mode: t
  hl-line-mode: t
  display-line-numbers-mode: t
  electric-pair-mode: t
  hl-todo-mode: t
  dtrt-indent-mode: t
  projectile-mode: t
  yas-minor-mode: t
  company-mode: t
  flycheck-posframe-mode: t
  flycheck-mode: t
  winner-mode: t
  global-auto-revert-mode: t
  save-place-mode: t
  override-global-mode: t
  vertico-mode: t
  which-key-mode: t
  global-evil-vimish-fold-mode: t
  evil-vimish-fold-mode: t
  vimish-fold-global-mode: t
  vimish-fold-mode: t
  global-evil-surround-mode: t
  evil-surround-mode: t
  evil-commentary-mode: t
  shell-dirtrack-mode: t
  evil-mode: t
  evil-local-mode: t
  windmove-mode: t
  straight-use-package-mode: t
  straight-package-neutering-mode: t
  straight-live-modifications-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  transient-mark-mode: t

Load-path shadows:
/home/blahgeek/.emacs.d/straight/build/protobuf-mode/protobuf-mode hides /usr/share/emacs/site-lisp/protobuf-mode
/home/blahgeek/.emacs.d/straight/build/cmake-mode/cmake-mode hides /usr/share/emacs/site-lisp/cmake-mode
/home/blahgeek/.emacs.d/straight/build/transient/transient hides /usr/share/emacs/28.1/lisp/transient
/home/blahgeek/.emacs.d/straight/build/let-alist/let-alist hides /usr/share/emacs/28.1/lisp/emacs-lisp/let-alist

Features:
(shadow sort mail-extr emacsbug sendmail vc-mtn vc-hg vc-bzr vc-src
vc-sccs vc-svn vc-cvs vc-rcs vc bug-reference evil-collection-magit
magit-bookmark magit-submodule magit-obsolete magit-blame magit-stash
magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone
magit-remote magit-commit magit-sequence magit-notes magit-worktree
magit-tag magit-merge magit-branch magit-reset magit-files magit-refs
magit-status magit evil-collection-package-menu package url-handlers
magit-repos magit-apply magit-wip magit-log which-func magit-diff
smerge-mode diff git-commit evil-collection-log-edit log-edit message
rfc822 mml mml-sec evil-collection-epa epa derived mm-decode mm-bodies
mm-encode mailabbrev gmm-utils pcvs-util add-log magit-core
magit-autorevert magit-margin magit-transient magit-process with-editor
magit-mode transient magit-git magit-base magit-section tabify crm
mule-util evil-collection-yaml-mode yaml-mode undo-fu descr-text
cl-print evil-collection-debug debug backtrace consult-xref
evil-collection-consult consult-vertico consult recentf eieio-opt
evil-collection-speedbar speedbar ezimage dframe
evil-collection-shortdoc shortdoc help-fns radix-tree url-file url-dired
url-cache url-auth vertico-directory orderless cursor-sensor
devdocs-browser evil-collection-eww eww xdg url-queue mm-url
evil-collection-gnus gnus nnheader gnus-util rmail rmail-loaddefs shr
kinsoku svg browse-url lsp-diagnostics lsp-modeline dap-mouse dap-ui
gdb-mi gud bui bui-list bui-info bui-entry bui-core bui-history
bui-button bui-utils evil-collection-custom cus-edit cus-start lsp-lens
evil-collection-view view lsp-zig lsp-steep lsp-svelte lsp-sqls lsp-yaml
lsp-xml lsp-vimscript lsp-vhdl lsp-volar lsp-vetur lsp-html lsp-verilog
lsp-vala lsp-v lsp-typeprof lsp-ttcn3 lsp-toml lsp-terraform lsp-tex
lsp-sorbet lsp-solargraph lsp-rust lsp-rf lsp-remark lsp-r
lsp-purescript lsp-pylsp lsp-pyls lsp-pwsh lsp-php lsp-perlnavigator
lsp-perl lsp-ocaml lsp-magik lsp-nix lsp-nim lsp-nginx lsp-markdown
lsp-lua lsp-kotlin lsp-json lsp-javascript lsp-idris lsp-haxe lsp-groovy
lsp-hack lsp-graphql lsp-go lsp-completion lsp-gdscript lsp-fsharp
lsp-fortran lsp-eslint lsp-erlang lsp-emmet lsp-elixir lsp-elm
lsp-dockerfile lsp-dhall lsp-d lsp-css lsp-csharp gnutls lsp-crystal
lsp-cmake lsp-clojure lsp-semantic-tokens lsp-clangd dom lsp-beancount
lsp-bash lsp-ansible lsp-angular lsp-ada lsp-actionscript
evil-collection-vc-git vc-git evil-collection-diff-mode diff-mode
vc-dispatcher lsp-haskell lsp-pyright dap-java dap-mode dap-launch
dap-overlays lsp-java request mailheader mail-utils lsp-treemacs
lsp-treemacs-themes treemacs treemacs-header-line treemacs-compatibility
treemacs-mode treemacs-bookmarks treemacs-interface treemacs-extensions
treemacs-mouse-interface treemacs-tags treemacs-persistence
treemacs-filewatch-mode treemacs-follow-mode treemacs-rendering
treemacs-async treemacs-workspaces treemacs-dom treemacs-visuals
treemacs-fringe-indicator treemacs-scope pulse treemacs-faces
treemacs-icons treemacs-themes treemacs-core-utils pfuture
treemacs-logging treemacs-customization treemacs-macros cc-mode cc-fonts
cc-guess cc-menus cc-cmds lsp-mode lsp-protocol tree-widget wid-edit
spinner network-stream puny nsm rmc evil-collection-markdown-mode
markdown-mode lv inline ht ewoc epg rfc6068 epg-config ligature
evil-collection-outline noutline outline whitespace hl-line
display-line-numbers elec-pair git-gutter-fringe fringe-helper
git-gutter hl-todo dtrt-indent projectile lisp-mnt mail-parse rfc2231
rfc2047 rfc2045 mm-util ietf-drums mail-prsvr evil-collection-grep grep
ibuf-ext evil-collection-ibuffer ibuffer ibuffer-loaddefs yasnippet
company-keywords company-etags company-gtags company-template
company-dabbrev-code company-dabbrev company-capf company-yasnippet
company-files company pcase flycheck-posframe posframe
flycheck-google-cpplint evil-collection-flycheck flycheck
evil-collection-imenu imenu evil-collection-go-mode go-mode url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap find-file ffap url-parse url-vars etags
fileloop generator evil-collection-xref xref project time
pydoc-autoloads suggest-autoloads loop-autoloads
devdocs-browser-autoloads server sudo-edit-autoloads dumb-jump-autoloads
popup-autoloads fcitx dbus xml fcitx-autoloads wgrep-ag-autoloads
wgrep-autoloads ag-autoloads git-link-autoloads pr-review-autoloads
ghub-autoloads treepy-autoloads magit-autoloads magit-section-autoloads
git-commit-autoloads transient-autoloads lsp-haskell-autoloads
lsp-pyright-autoloads lsp-java-autoloads dap-mode-autoloads
lsp-treemacs-autoloads bui-autoloads treemacs-autoloads cfrs-autoloads
hydra-autoloads pfuture-autoloads ace-window-autoloads avy-autoloads
request-autoloads lsp-mode-autoloads lv-autoloads spinner-autoloads
ht-autoloads flycheck-posframe-autoloads posframe-autoloads
flycheck-package-autoloads package-lint-autoloads
consult-flycheck-autoloads flycheck-autoloads let-alist-autoloads
pkg-info-autoloads epl-autoloads company-emoji-autoloads
company-autoloads yasnippet-autoloads winner projectile-autoloads vterm
evil-collection-bookmark bookmark pp tramp tramp-loaddefs trampver
tramp-integration files-x tramp-compat parse-time iso8601 time-date
ls-lisp format-spec auth-source eieio eieio-core eieio-loaddefs
password-cache json map face-remap evil-collection-compile compile
text-property-search evil-collection-term term disp-table ehelp
find-func vterm-module term/xterm xterm vterm-autoloads
with-editor-autoloads org-tree-slide-autoloads cc-styles cc-align
cc-engine cc-vars cc-defs google-c-style google-c-style-autoloads
cuda-mode-autoloads bpftrace-mode-autoloads dockerfile-mode-autoloads
jsonnet-mode-autoloads haskell-mode-autoloads lua-mode-autoloads
web-mode-autoloads typescript-mode-autoloads go-mode-autoloads
markdown-mode-autoloads xonsh-mode-autoloads groovy-mode-autoloads
kotlin-mode-autoloads yaml-mode-autoloads bazel-autoloads
gn-mode-autoloads protobuf-mode-autoloads jinja2-mode-autoloads
vimrc-mode-autoloads fish-mode-autoloads cmake-mode-autoloads
dtrt-indent-autoloads hl-todo-autoloads rainbow-mode-autoloads
git-gutter-fringe-autoloads fringe-helper-autoloads git-gutter-autoloads
autorevert filenotify saveplace cus-load embark-consult-autoloads
embark-autoloads consult-autoloads use-package-bind-key bind-key
easy-mmode evil-collection-vertico vertico vertico-autoloads
orderless-autoloads evil-collection-which-key which-key
which-key-autoloads fringe-scale emacs-fringe-scale-autoloads
add-node-modules-path-autoloads exec-path-from-shell-autoloads
switch-buffer-functions switch-buffer-functions-autoloads
solarized-light-theme solarized-theme solarized solarized-faces color
solarized-theme-autoloads evil-vimish-fold evil-vimish-fold-autoloads
vimish-fold f dash s vimish-fold-autoloads f-autoloads dash-autoloads
s-autoloads evil-surround evil-surround-autoloads evil-commentary
evil-commentary-integration evil-commentary-autoloads
use-package-delight evil-collection-tabulated-list
evil-collection-tab-bar evil-collection-simple
evil-collection-process-menu evil-collection-occur evil-collection-info
evil-collection-indent evil-collection-image image-mode
evil-collection-dired dired dired-loaddefs exif evil-collection-help
evil-collection-elisp-mode evil-collection-comint calc-ext
evil-collection-calc evil-collection-buff-menu evil-collection annalist
evil-collection-autoloads annalist-autoloads evil evil-integration
evil-maps evil-commands reveal flyspell ispell evil-jumps
evil-command-window evil-search evil-ex shell pcomplete comint
ansi-color evil-types evil-macros evil-repeat evil-states evil-core
advice evil-common windmove calc calc-loaddefs calc-macs thingatpt rect
evil-digraphs evil-vars ring edmacro kmacro evil-autoloads
goto-chg-autoloads undo-fu-autoloads ligature-autoloads delight comp
comp-cstr warnings rx delight-autoloads finder-inf use-package-core
use-package-autoloads bind-key-autoloads straight-autoloads cl-seq info
cl-extra help-mode seq byte-opt straight subr-x cl-macs gv cl-loaddefs
cl-lib bytecomp byte-compile cconv china-util iso-transl tooltip eldoc
paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode
mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 1441246 611296)
 (symbols 48 65553 5)
 (strings 32 473408 32915)
 (string-bytes 1 15632293)
 (vectors 16 113819)
 (vector-slots 8 3290339 1027112)
 (floats 8 1043 959)
 (intervals 56 47613 5332)
 (buffers 992 39))