Repository navigation
Entry in wildmenu is mutated when searching #17654
Description
Activity
This is working as intended. Note that
hlsearchhighlights correctly even when the case differs—for example, theoinwOrld. If you selectworldfrom the menu and press Enter, the cursor will jump to thewOrldmatch, as expected.Importantly, the portion of the search pattern already typed by the user is not modified when a completion item is inserted. This preserves special regex elements such as wildcards, grouping brackets, and word-boundary tags (
\<,\>,^, etc.), which is especially critical for predictable outcomes in commands like:s.The original design of the PR used a different approach: it expanded the pattern and displayed a literal fragment from the buffer (e.g.,
wO[rld]instead ofwo[rld]). While this may seem intuitive, it breaks in cases where regex anchors are used. For example, with a pattern like\<wo, if bothworldandwoworldexist in the buffer, expanding the pattern would remove the\<anchor and lead to incorrect matches. One of the menu items might beworldwithout the anchor, which would match[wo]world—not the intended behavior. The PR also attempted to re-insert\<s after pattern expansion, but doing so robustly proved difficult, since these anchors can appear anywhere.The current implementation takes a more reliable approach: it preserves the exact pattern typed by the user and appends only the suggested completion. Internally, it still expands the full pattern (including
\ns) to verifyignorecaseandsmartcase, but the menu displays only the completion portion appended to the original input. This ensures both accuracy and predictable behavior.I got the gist of it
But still changing entries in completion menu itself seems not ok. In my example, there is only
wOrldin the buffer text. Noworld. So I would expect to see only that in the menu.I got the gist of it
But still changing entries in completion menu itself seems not ok. In my example, there is only
wOrldin the buffer text. Noworld. So I would expect to see only that in the menu.Regex-based completion cannot behave the same way as Insert-mode completion, where users typically type simple words and the menu shows matching words from the buffer. In regex contexts, users may enter arbitrarily complex patterns. Modifying the user-typed pattern when inserting a completion item can lead to incorrect or unintended matches, as explained earlier. Preserving the original pattern is crucial.
I understand your dilemma, but this is the best I could come up with!
Reacted by techntools- added 5 commits that reference this issue
on Jul 5, 2025 - added a commit that references this issue
on Jul 8, 2025 - added 2 commits that reference this issue
on Jul 8, 2025
Steps to reproduce
@girishji Thank you for improving the Vim search
I tried code suggested in #17570. Compiled latest Vim.
I have
ignorecaseandsmartcaseonScreencast.from.2025-07-03.18-29-49.webm
Expected behaviour
I am expecting
w0rldstays the same in menu. But its changing in the menu itself.Version of Vim
Latest
Environment
Ubuntu 24
tmux in Kitty
Using bash
Logs and stack traces