mirror of
https://github.com/neovim/neovim.git
synced 2025-10-10 20:06:33 +00:00
timers: make repeat=0 work one-shot (consistent with vim)
This commit is contained in:
@@ -16639,6 +16639,9 @@ static void f_timer_start(typval_T *argvars, typval_T *rettv)
|
|||||||
}
|
}
|
||||||
if (dict_find(dict, (char_u *)"repeat", -1) != NULL) {
|
if (dict_find(dict, (char_u *)"repeat", -1) != NULL) {
|
||||||
repeat = get_dict_number(dict, (char_u *)"repeat");
|
repeat = get_dict_number(dict, (char_u *)"repeat");
|
||||||
|
if (repeat == 0) {
|
||||||
|
repeat = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,6 +22,14 @@ describe('timers', function()
|
|||||||
eq(1,eval("g:val"))
|
eq(1,eval("g:val"))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('works one-shot when repeat=0', function()
|
||||||
|
execute("call timer_start(50, 'MyHandler', {'repeat': 0})")
|
||||||
|
eq(0,eval("g:val"))
|
||||||
|
run(nil, nil, nil, 200)
|
||||||
|
eq(1,eval("g:val"))
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
it('works with repeat two', function()
|
it('works with repeat two', function()
|
||||||
execute("call timer_start(50, 'MyHandler', {'repeat': 2})")
|
execute("call timer_start(50, 'MyHandler', {'repeat': 2})")
|
||||||
eq(0,eval("g:val"))
|
eq(0,eval("g:val"))
|
||||||
|
Reference in New Issue
Block a user