]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.2039: completion shows current word after completion restart v9.0.2039
authornwounkn <nwounkn@gmail.com>
Tue, 17 Oct 2023 09:05:38 +0000 (11:05 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 17 Oct 2023 09:05:38 +0000 (11:05 +0200)
Problem:  completion shows current word after completion restart
Solution: remove the word being completed after completion restart

The word being completed is shown in a completion list after completion
restart, because it isn't removed from the current buffer before
searching for matches.

Also adjust `Test_complete_add_onechar` to match the new behavior.

closes: #13349

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

index f225cd3844663eea2e01f1e3134291e5469c1c64..ad4edc184e68ee59b03ee90ce0478d66e80f9414 100644 (file)
@@ -4157,7 +4157,7 @@ ins_compl_next(
        ins_compl_update_shown_match();
 
     if (allow_get_expansion && insert_match
-           && (!(compl_get_longest || compl_restarting) || compl_used_match))
+           && (!compl_get_longest || compl_used_match))
        // Delete old text to be replaced
        ins_compl_delete();
 
index c7f9e9b28bd5cf7cc3b7d5d717f0eebe4af08fa0..a4ac26e06c392e4aa0ea92073fd0d3046cb296f4 100644 (file)
@@ -818,7 +818,7 @@ func Test_complete_add_onechar()
   setlocal complete=.
   call setline(1, ['workhorse', 'workload'])
   normal Go
-  exe "normal aWOR\<C-P>\<bs>\<bs>\<bs>\<bs>\<bs>\<bs>\<C-L>r\<C-L>\<C-L>"
+  exe "normal aWOR\<C-P>\<bs>\<bs>\<bs>\<bs>\<bs>\<bs>\<C-L>\<C-L>\<C-L>"
   call assert_equal('workh', getline(3))
   set ignorecase& backspace&
   close!
@@ -2248,6 +2248,17 @@ func GetCompleteInfo()
   return ''
 endfunc
 
+func Test_completion_restart()
+  new
+  set complete=. completeopt=menuone backspace=2
+  call setline(1, 'workhorse workhorse')
+  exe "normal $a\<C-N>\<BS>\<BS>\<C-R>=GetCompleteInfo()\<CR>"
+  call assert_equal(1, len(g:compl_info['items']))
+  call assert_equal('workhorse', g:compl_info['items'][0]['word'])
+  set complete& completeopt& backspace&
+  bwipe!
+endfunc
+
 func Test_complete_info_index()
   new
   call setline(1, ["aaa", "bbb", "ccc", "ddd", "eee", "fff"])
index a0ac2d0772d4a58b24b7faa9d82eb22bb0c48162..208d7a8819a07d2726864f331aec063597497513 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2039,
 /**/
     2038,
 /**/