diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index 8625c0c1ca..cd5945731d 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -3147,7 +3147,15 @@ void f_complete_match(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) char *cur_end = before_cursor + (int)strlen(before_cursor); while (*p != NUL) { - size_t len = copy_option_part(&p, part, MAXPATHL, ","); + size_t len = 0; + if (*p == ',' && *(p + 1) == ' ' && (*(p + 2) == ',' || *(p + 2) == NUL)) { + part[0] = ' '; + len = 1; + p++; + } else { + len = copy_option_part(&p, part, MAXPATHL, ","); + } + if (len > 0 && (int)len <= col) { if (strncmp(cur_end - len, part, len) == 0) { int bytepos = col - (int)len; diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim index 7d2288d97b..9ca8d1661a 100644 --- a/test/old/testdir/test_ins_complete.vim +++ b/test/old/testdir/test_ins_complete.vim @@ -3775,6 +3775,10 @@ func Test_complete_match() call feedkeys("Sabc, \:let g:result=complete_match()\", 'tx') call assert_equal([[4, ',']], g:result) + set ise=\ ,= + call feedkeys("Sif true \:let g:result=complete_match()\", 'tx') + call assert_equal([[8, ' ']], g:result) + bw! unlet g:result set isexpand&