[vim/vim] helptoc navigation jumps incorrectly and flickers when hlsearch is active and using J/K (Issue #21051)

VimWei (Vim Github Repository) <[email protected]>
Newsgroups gmane.editors.vim.devel
Message-ID <vim/vim/issues/[email protected]>
VimWei created an issue (vim/vim#21051)

**Issue Description:**
When active search highlighting (`hlsearch`) is present in the buffer, navigating the `helptoc` popup menu via `J` / `K` causes screen flickering and incorrect cursor movement when changing heading depth levels.

---

**Steps to Reproduce:**

1. Create a Markdown file (e.g., `test.md`) with hierarchical headers:
```markdown
# level 1 a
## level 2 b
### level 3 c
### level 3 d
### level 3 e
### level 3 f

```


2. Open the file in GVIM and trigger search highlighting (e.g., `/level` and press `Enter`). Ensure `hlsearch` is active.
3. Open the table of contents popup via `:HelpToc`.
4. Press uppercase `J` or `K` to navigate through the popup entries.

---

**Observed Behavior:**

1. **Window Flickering:** Every keypress of `J` or `K` causes the `helptoc` popup window to flicker/redraw.
2. **First Jump Lag on Depth Change:** When moving between different heading levels (e.g., from `## level 2 b` down to `### level 3 c`):
* **1st press of `J`:** The cursor remains stuck at `## level 2 b`.
* **2nd press of `J`:** The cursor finally jumps to `### level 3 c`.


3. **Unexpected Cursor Retreat:** Continuing to press `J` to move from `### level 3 c` down to `### level 3 d` causes the window to flicker and the cursor to incorrectly jump back up to `## level 2 b`.

---

**Expected Behavior:**
`helptoc` navigation using `J` / `K` should smoothly move between heading items regardless of active search highlighting (`hlsearch`), without screen flickering or incorrect level jumps.

---

**Environment:**

* **OS:** Windows 10
* **Vim Version:** gVim 9.2.0907 x64 (signed)
* **Terminal/GUI:** gVim (GUI)

-- 
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/issues/21051
You are receiving this because you are subscribed to this thread.

Message ID: <vim/vim/issues/[email protected]>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/vim/vim/issues/21051%40github.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.