Skip to content

Commit b650b98

Browse files
committed
patch 7.4.2158
Problem: Result of getcompletion('', 'cscope') depends on previous completion. (Christian Brabandt) Solution: Call set_context_in_cscope_cmd().
1 parent 46c4d4a commit b650b98

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

src/evalfunc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4240,6 +4240,13 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
42404240
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
42414241
}
42424242
# endif
4243+
#ifdef FEAT_CSCOPE
4244+
if (xpc.xp_context == EXPAND_CSCOPE)
4245+
{
4246+
set_context_in_cscope_cmd(&xpc, xpc.xp_pattern, CMD_cscope);
4247+
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
4248+
}
4249+
#endif
42434250

42444251
pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context);
42454252
if ((rettv_list_alloc(rettv) != FAIL) && (pat != NULL))

src/testdir/test_cmdline.vim

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,22 @@ func Test_getcompletion()
125125
let l = getcompletion('dark', 'highlight')
126126
call assert_equal([], l)
127127

128+
if has('cscope')
129+
let l = getcompletion('', 'cscope')
130+
let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show']
131+
call assert_equal(cmds, l)
132+
" using cmdline completion must not change the result
133+
call feedkeys(":cscope find \<c-d>\<c-c>", 'xt')
134+
let l = getcompletion('', 'cscope')
135+
call assert_equal(cmds, l)
136+
let keys = ['a', 'c', 'd', 'e', 'f', 'g', 'i', 's', 't']
137+
let l = getcompletion('find ', 'cscope')
138+
call assert_equal(keys, l)
139+
endif
140+
128141
" For others test if the name is recognized.
129142
let names = ['buffer', 'environment', 'file_in_path',
130143
\ 'mapping', 'shellcmd', 'tag', 'tag_listfiles', 'user']
131-
if has('cscope')
132-
call add(names, 'cscope')
133-
endif
134144
if has('cmdline_hist')
135145
call add(names, 'history')
136146
endif

src/version.c

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

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2158,
766768
/**/
767769
2157,
768770
/**/

0 commit comments

Comments
 (0)