Skip to content

Commit 2e3cd52

Browse files
nwounknchrisbra
authored andcommitted
patch 9.0.2039: completion shows current word after completion restart
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 <[email protected]> Co-authored-by: nwounkn <[email protected]>
1 parent f3eac69 commit 2e3cd52

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/insexpand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4157,7 +4157,7 @@ ins_compl_next(
41574157
ins_compl_update_shown_match();
41584158

41594159
if (allow_get_expansion && insert_match
4160-
&& (!(compl_get_longest || compl_restarting) || compl_used_match))
4160+
&& (!compl_get_longest || compl_used_match))
41614161
// Delete old text to be replaced
41624162
ins_compl_delete();
41634163

src/testdir/test_ins_complete.vim

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ func Test_complete_add_onechar()
818818
setlocal complete=.
819819
call setline(1, ['workhorse', 'workload'])
820820
normal Go
821-
exe "normal aWOR\<C-P>\<bs>\<bs>\<bs>\<bs>\<bs>\<bs>\<C-L>r\<C-L>\<C-L>"
821+
exe "normal aWOR\<C-P>\<bs>\<bs>\<bs>\<bs>\<bs>\<bs>\<C-L>\<C-L>\<C-L>"
822822
call assert_equal('workh', getline(3))
823823
set ignorecase& backspace&
824824
close!
@@ -2248,6 +2248,17 @@ func GetCompleteInfo()
22482248
return ''
22492249
endfunc
22502250

2251+
func Test_completion_restart()
2252+
new
2253+
set complete=. completeopt=menuone backspace=2
2254+
call setline(1, 'workhorse workhorse')
2255+
exe "normal $a\<C-N>\<BS>\<BS>\<C-R>=GetCompleteInfo()\<CR>"
2256+
call assert_equal(1, len(g:compl_info['items']))
2257+
call assert_equal('workhorse', g:compl_info['items'][0]['word'])
2258+
set complete& completeopt& backspace&
2259+
bwipe!
2260+
endfunc
2261+
22512262
func Test_complete_info_index()
22522263
new
22532264
call setline(1, ["aaa", "bbb", "ccc", "ddd", "eee", "fff"])

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
2039,
707709
/**/
708710
2038,
709711
/**/

0 commit comments

Comments
 (0)