Merge pull request #23313 from zeertzjq/vim-8.2.3768

vim-patch:8.2.{3768,3772}
This commit is contained in:
zeertzjq 2023-04-25 22:49:57 +08:00 committed by GitHub
commit c111460b1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -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);
}
})

View File

@ -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 {

View File

@ -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()