My recent test shows this also happens when you modify overlay in the buffer
frequently. Also, a timer is not needed, it happens when it's frequent enough.
Recipe:
1. emacs -Q
2. Eval this:
(require 'paren)
(add-hook 'post-command-hook
(lambda ()
(let ((show-paren-mode t))
(show-paren-function))))
It's a setup to run show-paren-function in post-command-hook. Directly using
show-paren-mode also cause the bug, but the chance is way lower, as it
delays the refreshing using a timer. It happens to me occasionally when I'm
coding with show-paren-mode on.
3. M-x find-library RET paren
4. M-x split-window-horizontally
5. Move to a position in the left window where there's a bunch of closing
parens. You should see show-paren-function is highting them for you.
6. Scroll the right window to a position where you can see the matching opening
parens. Now show-paren-function should highlight opening parens in the right
window, and closing parens in the left window.
7. Go back to the left window. Hold Ctrl and press f/b/g at the same time
several times (so you are sending C-f, C-b and C-g frequently)
8. The cursor in the left window will jump to the position of the
right window cursor.
I've attached a gif so you could see it clealy.
At this time, I think the bug occurs when you frequently write text to
header-line, mode-line, minibuffer (see
https://github.com/kiennq/emacs-mini-modeline/issues/45), or operate on
overlays. Using a timer or not doesn't matter.
This has been bugging me for years since company-mode (uses overlay + timer)
also causes this problem. I haven't seen similar bug reports, though. Am I the
only unlucky company user? Could someone save me from the pain?
Emacs version: GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.30, cairo version 1.17.4) of 2021-08-11