]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1265: tests: no tests for typing normal char during completion v9.1.1265
authorChristian Brabandt <cb@256bit.org>
Mon, 31 Mar 2025 18:57:13 +0000 (20:57 +0200)
committerChristian Brabandt <cb@256bit.org>
Mon, 31 Mar 2025 18:57:13 +0000 (20:57 +0200)
Problem:  tests: no tests for typing normal char during completion
Solution: add a test verifying the default behaviour (see :h
          popupmenu-completion)

related: #17019

Co-authored-by: Girish Palya <girishji@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/testdir/test_ins_complete.vim
src/version.c

index 7b180a64e43a9f718fb86bc7ed2f953df4887c34..50b18346916c7226675def6ae38d9d72ffa3d0b5 100644 (file)
@@ -3387,4 +3387,33 @@ func Test_complete_multiline_marks()
   delfunc Omni_test
 endfunc
 
+func Test_complete_append_selected_match_default()
+  " when typing a normal character during completion,
+  " completion is ended, see
+  " :h popupmenu-completion ("There are three states:")
+  func PrintMenuWords()
+    let info = complete_info(["selected", "matches"])
+    call map(info.matches, {_, v -> v.word})
+    return info
+  endfunc
+
+  new
+  call setline(1, ["fo", "foo", "foobar", "fobarbaz"])
+  exe "normal! Gof\<c-n>\<c-r>=PrintMenuWords()\<cr>"
+  call assert_equal('fo{''matches'': [''fo'', ''foo'', ''foobar'', ''fobarbaz''], ''selected'': 0}', getline(5))
+  %d
+  call setline(1, ["fo", "foo", "foobar", "fobarbaz"])
+  exe "normal! Gof\<c-n>o\<c-r>=PrintMenuWords()\<cr>"
+  call assert_equal('foo{''matches'': [], ''selected'': -1}', getline(5))
+  %d
+  set completeopt=menu,noselect
+  call setline(1, ["fo", "foo", "foobar", "fobarbaz"])
+  exe "normal! Gof\<c-n>\<c-n>o\<c-r>=PrintMenuWords()\<cr>"
+  call assert_equal('foo{''matches'': [], ''selected'': -1}', getline(5))
+  bw!
+
+  set completeopt&
+  delfunc PrintMenuWords
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab nofoldenable
index 67affb2e18c054ed541395cbbe993f7628d0a955..50632747be980d224a18cb5c70618258d60866d9 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1265,
 /**/
     1264,
 /**/