diff options
-rw-r--r-- | src/nvim/eval.c | 3 | ||||
-rw-r--r-- | test/functional/eval/timer_spec.lua | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f45612a886..06ed3407dd 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -16639,6 +16639,9 @@ static void f_timer_start(typval_T *argvars, typval_T *rettv) } if (dict_find(dict, (char_u *)"repeat", -1) != NULL) { repeat = get_dict_number(dict, (char_u *)"repeat"); + if (repeat == 0) { + repeat = 1; + } } } diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua index 82b965c832..2f83edb9e4 100644 --- a/test/functional/eval/timer_spec.lua +++ b/test/functional/eval/timer_spec.lua @@ -22,6 +22,14 @@ describe('timers', function() eq(1,eval("g:val")) 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() execute("call timer_start(50, 'MyHandler', {'repeat': 2})") eq(0,eval("g:val")) |