Skip to content

Commit ffd99f7

Browse files
committed
patch 8.0.1242: function argument with only dash is seen as number zero
Problem: Function argument with only dash is seen as number zero. (Wang Shidong) Solution: See a dash as a string. (Christian Brabandt)
1 parent 89c394f commit ffd99f7

4 files changed

Lines changed: 28 additions & 1 deletion

File tree

src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,7 @@ test_arglist \
21892189
test_hlsearch \
21902190
test_increment \
21912191
test_increment_dbcs \
2192+
test_ins_complete \
21922193
test_job_fails \
21932194
test_join \
21942195
test_json \

src/eval.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,8 +1056,13 @@ call_vim_function(
10561056
if (str_arg_only)
10571057
len = 0;
10581058
else
1059-
/* Recognize a number argument, the others must be strings. */
1059+
{
1060+
/* Recognize a number argument, the others must be strings. A dash
1061+
* is a string too. */
10601062
vim_str2nr(argv[i], NULL, &len, STR2NR_ALL, &n, NULL, 0);
1063+
if (len == 1 && *argv[i] == '-')
1064+
len = 0;
1065+
}
10611066
if (len != 0 && len == (int)STRLEN(argv[i]))
10621067
{
10631068
argvars[i].v_type = VAR_NUMBER;

src/testdir/test_ins_complete.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,22 @@ func Test_ins_complete()
9090
call delete('Xtestdata')
9191
set cpt& cot& def& tags& tagbsearch& hidden&
9292
endfunc
93+
94+
func Test_omni_dash()
95+
func Omni(findstart, base)
96+
if a:findstart
97+
return 5
98+
else
99+
echom a:base
100+
return ['-help', '-v']
101+
endif
102+
endfunc
103+
set omnifunc=Omni
104+
new
105+
exe "normal Gofind -\<C-x>\<C-o>"
106+
call assert_equal("\n-\nmatch 1 of 2", execute(':2mess'))
107+
108+
bwipe!
109+
delfunc Omni
110+
set omnifunc=
111+
endfunc

src/version.c

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

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1242,
764766
/**/
765767
1241,
766768
/**/

0 commit comments

Comments
 (0)