diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c index cd5945731d..66ba5db4e9 100644 --- a/src/nvim/insexpand.c +++ b/src/nvim/insexpand.c @@ -3144,15 +3144,20 @@ void f_complete_match(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } } else { char *p = ise; + char *p_space = NULL; char *cur_end = before_cursor + (int)strlen(before_cursor); while (*p != NUL) { size_t len = 0; - if (*p == ',' && *(p + 1) == ' ' && (*(p + 2) == ',' || *(p + 2) == NUL)) { - part[0] = ' '; - len = 1; - p++; + if (p_space) { + len = (size_t)(p - p_space - 1); + memcpy(part, p_space + 1, len); + p_space = NULL; } else { + char *next_comma = strchr((*p == ',') ? p + 1 : p, ','); + if (next_comma && *(next_comma + 1) == ' ') { + p_space = next_comma; + } len = copy_option_part(&p, part, MAXPATHL, ","); } diff --git a/test/old/testdir/test_ins_complete.vim b/test/old/testdir/test_ins_complete.vim index 9ca8d1661a..62fe6385ff 100644 --- a/test/old/testdir/test_ins_complete.vim +++ b/test/old/testdir/test_ins_complete.vim @@ -3778,6 +3778,13 @@ func Test_complete_match() set ise=\ ,= call feedkeys("Sif true \:let g:result=complete_match()\", 'tx') call assert_equal([[8, ' ']], g:result) + call feedkeys("Slet a = \:let g:result=complete_match()\", 'tx') + call assert_equal([[7, '=']], g:result) + set ise={,\ ,= + call feedkeys("Sif true \:let g:result=complete_match()\", 'tx') + call assert_equal([[8, ' ']], g:result) + call feedkeys("S{ \:let g:result=complete_match()\", 'tx') + call assert_equal([[1, '{']], g:result) bw! unlet g:result