patch 9.1.1424: PMenu selection broken with multi-line selection and limits
Problem: PMenu selection broken with multi-line selection and limits
(Maxim Kim)
Solution: update completion match index when limiting the completion
sources (Girish Palya)
fixes: #17394
closes: #17401
Signed-off-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index dfc2189..f3c29d1 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -4238,7 +4238,33 @@
call assert_equal('abac', getline(4))
bw!
- set completeopt& complete&
+ " Items with '\n' that cause menu to shift, with no leader (issue #17394)
+ func! ComplFunc(findstart, base)
+ if a:findstart == 1
+ return col('.') - 1
+ endif
+ return ["one\ntwo\nthree", "four five six", "hello\nworld\nhere"]
+ endfunc
+ set completeopt=menuone,popup,noselect,fuzzy infercase
+ set complete=.^1,FComplFunc^5
+ new
+ call setline(1, ["foo", "bar", "baz"])
+ execute "normal Go\<c-n>\<c-n>\<c-n>"
+ call assert_equal(['one', 'two', 'three'], getline(4, 6))
+ %d
+ call setline(1, ["foo", "bar", "baz"])
+ execute "normal Go\<c-n>\<c-n>\<c-n>\<c-p>"
+ call assert_equal('foo', getline(4))
+ execute "normal S\<c-n>\<c-n>\<c-n>\<c-n>\<c-n>\<c-n>\<c-n>"
+ call assert_equal('foo', getline(4))
+ set complete=.^1,FComplFunc^2
+ execute "normal S\<c-n>\<c-n>\<c-n>\<c-n>\<c-n>\<c-n>"
+ call assert_equal('foo', getline(4))
+ execute "normal S\<c-n>\<c-p>\<c-p>\<c-p>\<c-n>\<c-n>"
+ call assert_equal('four five six', getline(4))
+ bw!
+
+ set completeopt& complete& infercase&
delfunc PrintMenuWords
delfunc ComplFunc
delfunc CompleteItemsSelect