commit c111460b1a2686de3892a40f71e5ae21bdbae8b7
parent bfa92d3861e425b59f9b1793c08247965a8e53f5
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue, 25 Apr 2023 22:49:57 +0800
Merge pull request #23313 from zeertzjq/vim-8.2.3768
vim-patch:8.2.{3768,3772}
Diffstat:
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
@@ -6002,7 +6002,7 @@ void add_timer_info_all(typval_T *rettv)
tv_list_alloc_ret(rettv, map_size(&timers));
timer_T *timer;
map_foreach_value(&timers, timer, {
- if (!timer->stopped) {
+ if (!timer->stopped || timer->refcount > 1) {
add_timer_info(rettv, timer);
}
})
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
@@ -8944,7 +8944,7 @@ static void f_timer_info(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
tv_list_alloc_ret(rettv, 1);
timer_T *timer = find_timer_by_nr(tv_get_number(&argvars[0]));
- if (timer != NULL && !timer->stopped) {
+ if (timer != NULL && (!timer->stopped || timer->refcount > 1)) {
add_timer_info(rettv, timer);
}
} else {
diff --git a/test/old/testdir/test_timers.vim b/test/old/testdir/test_timers.vim
@@ -94,6 +94,12 @@ func Test_timer_info()
call assert_equal([], timer_info(id))
call assert_fails('call timer_info("abc")', 'E39:')
+
+ " check repeat count inside the callback
+ let g:timer_repeat = []
+ let tid = timer_start(10, {tid -> execute("call add(g:timer_repeat, timer_info(tid)[0].repeat)")}, #{repeat: 3})
+ call WaitForAssert({-> assert_equal([2, 1, 0], g:timer_repeat)})
+ unlet g:timer_repeat
endfunc
func Test_timer_stopall()