Context
I initially reported this to the Vim issue tracker (vim/vim#21051), but I bisected it down to vim-cool: with vim-cool enabled the problem occurs; after disabling it, everything works as expected. So this is very likely a vim-cool bug, not a Vim bug.
Steps to reproduce
-
Create test.md with hierarchical headers:
# level 1 a
## level 2 b
### level 3 c
### level 3 d
### level 3 e
### level 3 f
-
set hlsearch, then search /level and press Enter so v:hlsearch is 1.
-
Open the :HelpToc popup.
-
Press J / K to move through the popup entries.
Observed behavior
- Every
J/K press makes the popup flicker/redraw.
- When moving across heading depths (e.g. from
## level 2 b down to ### level 3 c), the first J keeps the cursor on ## level 2 b; the second J finally moves to ### level 3 c.
- Continuing to
### level 3 d makes the cursor retreat back up to ## level 2 b.
Expected behavior
J/K should move smoothly through the popup entries regardless of hlsearch state, with no flicker or wrong jumps.
Possible cause
s:StartHL() runs from the CursorMoved autocommand, which also fires in popup windows (the helptoc buffer). It calls winsaveview(), go<byte>, norm! n, and winrestview() inside the popup buffer, which conflicts with the popup's own cursor management — the n search-move inside the popup is likely what causes the wrong jump and the redraw flicker. The popup's cursor position is not properly restored by winrestview().
If vim-cool could skip popup windows (e.g. ignore buffers where buftype is popup, or bail out when inside a popup), the problem would likely disappear.
Environment
- OS: Windows 10
- Vim: gVim 9.2.0907 x64
- vim-cool: latest master
Context
I initially reported this to the Vim issue tracker (vim/vim#21051), but I bisected it down to vim-cool: with vim-cool enabled the problem occurs; after disabling it, everything works as expected. So this is very likely a vim-cool bug, not a Vim bug.
Steps to reproduce
Create
test.mdwith hierarchical headers:set hlsearch, then search/leveland press Enter sov:hlsearchis 1.Open the
:HelpTocpopup.Press
J/Kto move through the popup entries.Observed behavior
J/Kpress makes the popup flicker/redraw.## level 2 bdown to### level 3 c), the firstJkeeps the cursor on## level 2 b; the secondJfinally moves to### level 3 c.### level 3 dmakes the cursor retreat back up to## level 2 b.Expected behavior
J/Kshould move smoothly through the popup entries regardless ofhlsearchstate, with no flicker or wrong jumps.Possible cause
s:StartHL()runs from theCursorMovedautocommand, which also fires in popup windows (the helptoc buffer). It callswinsaveview(),go<byte>,norm! n, andwinrestview()inside the popup buffer, which conflicts with the popup's own cursor management — thensearch-move inside the popup is likely what causes the wrong jump and the redraw flicker. The popup's cursor position is not properly restored bywinrestview().If vim-cool could skip popup windows (e.g. ignore buffers where
buftypeispopup, or bail out when inside a popup), the problem would likely disappear.Environment