Repository navigation
PMenu selection is not retained if multiline text is inserted #17394
Copy link
Copy link
Closed
Labels
Description
Activity
Minimal repro steps:
vim --clean- paste following and
:source
vim9script set completeopt=menuone,popup,noselect,fuzzy set infercase set complete=.^1,FMyComplete^5 def g:MyComplete(findstart: number, base: string): any if findstart == 1 return col('.') - 1 endif var items = ["one\ntwo\nthree", "four five six", "hello\nworld\nhere"] return items enddef- execute
Go<CTRL-N><CTRL-N>
You can see
one two threeinserted but selection is gone.
If you continue pressing
CTRL-Nmultiple times, you might get segmentation fault:@girishji this doesn't happen if I use
completefuncwithC-X C-U:vim9script set completeopt=menuone,popup,noselect,fuzzy set completefunc=MyComplete def g:MyComplete(findstart: number, base: string): any if findstart == 1 return col('.') - 1 endif var items = ["one\ntwo\nthree", "four five six", "hello\nworld\nhere"] return items enddefNo segfault and menu selection is correct:
PS
Also works fine with this:
vim9script set completeopt=menuone,popup,noselect,fuzzy set completefunc=MyComplete set complete=F def g:MyComplete(findstart: number, base: string): any if findstart == 1 return col('.') - 1 endif var items = ["one\ntwo\nthree", "four five six", "hello\nworld\nhere"] return items enddefpressing
C-n-- no segfaultHowever if you add
.^1or any other limit -- it has this issue (wrong pmenu selection and eventual segfault on continuousC-npresses)vim9script set completeopt=menuone,popup,noselect,fuzzy set completefunc=MyComplete set complete=.^1,F def g:MyComplete(findstart: number, base: string): any if findstart == 1 return col('.') - 1 endif var items = ["one\ntwo\nthree", "four five six", "hello\nworld\nhere"] return items enddefI'll take a look.
- added a commit that references this issue
on Jun 1, 2025 - added 2 commits that reference this issue
on Jun 2, 2025
Steps to reproduce
If inserted text is multilined it could shift selected pmenu item to another one:
In the asciicast you can see that after selecting the second item it inserts contents but selection is shifted to the first(previous) menu item.
Will try to come up with a simple reproducible steps later.
Context: I have added registers completion source for custom autocomplete to be able to complete the whole contents of registers in contrast to CTRL-X CTRL-R that completes only words from registers.
Expected behaviour
Selection in Pmenu should be retained
Version of Vim
9.1.1418
Environment
Debian12, bash
Logs and stack traces