vim-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)
ffd99f729b
This commit is contained in:
Jan Edmund Lazo 2018-08-22 13:00:42 -04:00
parent a466bd2927
commit eaf8e57cf9
2 changed files with 24 additions and 1 deletions

View File

@ -1210,8 +1210,12 @@ int call_vim_function(
if (str_arg_only) { if (str_arg_only) {
len = 0; len = 0;
} else { } else {
// Recognize a number argument, the others must be strings. // Recognize a number argument, the others must be strings. A dash
// is a string too.
vim_str2nr(argv[i], NULL, &len, STR2NR_ALL, &n, NULL, 0); vim_str2nr(argv[i], NULL, &len, STR2NR_ALL, &n, NULL, 0);
if (len == 1 && *argv[i] == '-') {
len = 0;
}
} }
if (len != 0 && len == (int)STRLEN(argv[i])) { if (len != 0 && len == (int)STRLEN(argv[i])) {
argvars[i].v_type = VAR_NUMBER; argvars[i].v_type = VAR_NUMBER;

View File

@ -217,3 +217,22 @@ function Test_CompleteDoneList()
let s:called_completedone = 0 let s:called_completedone = 0
au! CompleteDone au! CompleteDone
endfunc endfunc
func Test_omni_dash()
func Omni(findstart, base)
if a:findstart
return 5
else
echom a:base
return ['-help', '-v']
endif
endfunc
set omnifunc=Omni
new
exe "normal Gofind -\<C-x>\<C-o>"
call assert_equal("\n-\nmatch 1 of 2", execute(':2mess'))
bwipe!
delfunc Omni
set omnifunc=
endfunc