Skip to content

Commit 93c8f82

Browse files
committed
Merge remote-tracking branch 'vim/master'
2 parents c8a877b + 7ab6def commit 93c8f82

File tree

10 files changed

+105
-34
lines changed

10 files changed

+105
-34
lines changed

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,7 @@ test_arglist \
21032103
test_history \
21042104
test_increment \
21052105
test_increment_dbcs \
2106+
test_job_fails \
21062107
test_join \
21072108
test_json \
21082109
test_jumps \

src/dict.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ dict_find(dict_T *d, char_u *key, int len)
418418
/*
419419
* Get a string item from a dictionary.
420420
* When "save" is TRUE allocate memory for it.
421+
* When FALSE a shared buffer is used, can only be used once!
421422
* Returns NULL if the entry doesn't exist or out of memory.
422423
*/
423424
char_u *

src/evalfunc.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4247,6 +4247,13 @@ f_getcompletion(typval_T *argvars, typval_T *rettv)
42474247
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
42484248
}
42494249
# endif
4250+
#ifdef FEAT_CSCOPE
4251+
if (xpc.xp_context == EXPAND_CSCOPE)
4252+
{
4253+
set_context_in_cscope_cmd(&xpc, xpc.xp_pattern, CMD_cscope);
4254+
xpc.xp_pattern_len = (int)STRLEN(xpc.xp_pattern);
4255+
}
4256+
#endif
42504257

42514258
pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context);
42524259
if ((rettv_list_alloc(rettv) != FAIL) && (pat != NULL))
@@ -9679,11 +9686,11 @@ f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
96799686
}
96809687
}
96819688

9682-
group = get_dict_string(d, (char_u *)"group", FALSE);
9689+
group = get_dict_string(d, (char_u *)"group", TRUE);
96839690
priority = (int)get_dict_number(d, (char_u *)"priority");
96849691
id = (int)get_dict_number(d, (char_u *)"id");
96859692
conceal = dict_find(d, (char_u *)"conceal", -1) != NULL
9686-
? get_dict_string(d, (char_u *)"conceal", FALSE)
9693+
? get_dict_string(d, (char_u *)"conceal", TRUE)
96879694
: NULL;
96889695
if (i == 0)
96899696
{
@@ -9697,6 +9704,8 @@ f_setmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
96979704
list_unref(s);
96989705
s = NULL;
96999706
}
9707+
vim_free(group);
9708+
vim_free(conceal);
97009709

97019710
li = li->li_next;
97029711
}

src/testdir/Make_all.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ NEW_TESTS = test_arglist.res \
176176
test_history.res \
177177
test_increment.res \
178178
test_increment_dbcs.res \
179+
test_job_fails.res \
179180
test_json.res \
180181
test_langmap.res \
181182
test_man.res \

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/testdir/test_cscope.vim

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ func Test_cscope1()
4040
call assert_true(0)
4141
endtry
4242
call assert_fails('cscope add Xcscope.out', 'E568')
43+
call assert_fails('cscope add doesnotexist.out', 'E563')
44+
call assert_fails('cscope kill 2', 'E261')
4345
" Test 1: Find this C-Symbol
4446
let a=execute('cscope find s main')
4547
" Test 1.1 test where it moves the cursor
@@ -89,9 +91,12 @@ func Test_cscope1()
8991
call assert_equal(['','"Xmemfile_test.c" 143L, 3137C','(1 of 1): <<global>> #include <assert.h>'], split(a, '\n', 1))
9092
call assert_equal('#include <assert.h>', getline('.'))
9193

92-
" Test 9: Find places where this symbol is assigned a value
94+
" Test 9: Invalid find command
95+
call assert_fails('cs find x', 'E560')
96+
97+
" Test 10: Find places where this symbol is assigned a value
9398
" this needs a cscope >= 15.8
94-
" unfortunatly, Travis has cscope version 15.7
99+
" unfortunately, Travis has cscope version 15.7
95100
let cscope_version=systemlist('cscope --version')[0]
96101
let cs_version=str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?'))
97102
if cs_version >= 15.8
@@ -106,12 +111,12 @@ func Test_cscope1()
106111
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
107112
endif
108113

109-
" Test 10: leading whitespace is not removed for cscope find text
114+
" Test 11: leading whitespace is not removed for cscope find text
110115
let a=execute('cscope find t test_mf_hash')
111116
call assert_equal(['', '(1 of 1): <<<unknown>>> test_mf_hash();'], split(a, '\n', 1))
112117
call assert_equal(' test_mf_hash();', getline('.'))
113118

114-
" Test 11: cscope help
119+
" Test 12: cscope help
115120
let a=execute('cscope help')
116121
call assert_match('^cscope commands:\n', a)
117122
call assert_match('\nadd :', a)
@@ -121,20 +126,44 @@ func Test_cscope1()
121126
call assert_match('\nreset: Reinit all connections', a)
122127
call assert_match('\nshow : Show connections', a)
123128

124-
" Test 12: reset connections
129+
" Test 13: reset connections
125130
let a=execute('cscope reset')
126131
call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a)
127132
call assert_match('\nAll cscope databases reset', a)
128133

129-
" Test 13: cscope show
134+
" Test 14: cscope show
130135
let a=execute('cscope show')
131136
call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a)
132137

133-
" Test 14: 'csprg' option
138+
" Test 15: cstag and 'csto' option
139+
set csto=0
140+
let a=execute('cstag TEST_COUNT')
141+
call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a)
142+
call assert_equal('#define TEST_COUNT 50000', getline('.'))
143+
set csto=1
144+
let a=execute('cstag index_to_key')
145+
call assert_match('(1 of 1): <<index_to_key>> #define index_to_key(i) ((i) ^ 15167)', a)
146+
call assert_equal('#define index_to_key(i) ((i) ^ 15167)', getline('.'))
147+
call assert_fails('cstag xxx', 'E257')
148+
call assert_fails('cstag', 'E562')
149+
150+
" Test 15: 'csprg' option
134151
call assert_equal('cscope', &csprg)
135152

153+
" Test 16: 'cst' option
154+
set cst
155+
let a=execute('tag TEST_COUNT')
156+
call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a)
157+
call assert_equal('#define TEST_COUNT 50000', getline('.'))
158+
set nocst
159+
call assert_fails('tag TEST_COUNT', 'E426')
160+
136161
" CleanUp
137162
call CscopeSetupOrClean(0)
163+
164+
" cscope command should fail after killing scope connection.
165+
call assert_fails('cscope find s main', 'E567')
166+
138167
endfunc
139168

140169
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_expr.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,16 @@ func Test_funcref()
194194
let OneByRef = funcref('One')
195195
call assert_equal(2, OneByRef())
196196
endfunc
197+
198+
func Test_setmatches()
199+
hi def link 1 Comment
200+
hi def link 2 PreProc
201+
let set = [{"group": 1, "pattern": 2, "id": 3, "priority": 4}]
202+
let exp = [{"group": '1', "pattern": '2', "id": 3, "priority": 4}]
203+
if has('conceal')
204+
let set[0]['conceal'] = 5
205+
let exp[0]['conceal'] = '5'
206+
endif
207+
call setmatches(set)
208+
call assert_equal(exp, getmatches())
209+
endfunc

src/testdir/test_job_fails.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
" This test is in a separate file, because it usually causes reports for memory
2+
" leaks under valgrind. That is because when fork/exec fails memory is not
3+
" freed. Since the process exists right away it's not a real leak.
4+
5+
source shared.vim
6+
7+
func Test_job_start_fails()
8+
if has('job')
9+
let g:job = job_start('axdfxsdf')
10+
if has('unix')
11+
call WaitFor('job_status(g:job) == "dead"')
12+
call assert_equal('dead', job_status(g:job))
13+
else
14+
call WaitFor('job_status(g:job) == "fail"')
15+
call assert_equal('fail', job_status(g:job))
16+
endif
17+
unlet g:job
18+
endif
19+
endfunc

src/testdir/test_partial.vim

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
" Test binding arguments to a Funcref.
22

3-
" NOTE: This function may cause memory leaks to be reported.
4-
" That is because when fork/exec fails memory is not freed. Since the process
5-
" exists right away it's not a real leak.
6-
func Test_job_start_fails()
7-
if has('job')
8-
let job = job_start('axdfxsdf')
9-
for i in range(100)
10-
let status = job_status(job)
11-
if status == 'dead' || status == 'fail'
12-
break
13-
endif
14-
sleep 10m
15-
endfor
16-
if has('unix')
17-
call assert_equal('dead', job_status(job))
18-
else
19-
call assert_equal('fail', job_status(job))
20-
endif
21-
unlet job
22-
endif
23-
endfunc
24-
253
func MyFunc(arg1, arg2, arg3)
264
return a:arg1 . '/' . a:arg2 . '/' . a:arg3
275
endfunc

src/version.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,16 @@ static char *(features[]) =
778778

779779
static int included_patches[] =
780780
{ /* Add new patch number below this line */
781+
/**/
782+
2161,
783+
/**/
784+
2160,
785+
/**/
786+
2159,
787+
/**/
788+
2158,
789+
/**/
790+
2157,
781791
/**/
782792
2156,
783793
/**/

0 commit comments

Comments
 (0)