Skip to content

helptoc popup J/K navigation flickers and jumps with hlsearch on #55

Description

@VimWei

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

  1. Create test.md with hierarchical headers:

    # level 1 a
    ## level 2 b
    ### level 3 c
    ### level 3 d
    ### level 3 e
    ### level 3 f
    
  2. set hlsearch, then search /level and press Enter so v:hlsearch is 1.

  3. Open the :HelpToc popup.

  4. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions