Patch 8.2.3768
Problem:    timer_info() has the wrong repeat value in a timer callback.
            (Sergey Vlasov)
Solution:   Do not add one to the repeat value when in the callback.
            (closes #9294)
Files:      src/time.c, src/testdir/test_timers.vim


*** ../vim-8.2.3767/src/time.c  2021-12-09 10:50:48.566865615 +0000
--- src/time.c  2021-12-09 18:41:08.782206541 +0000
***************
*** 696,702 ****
      dict_add_number(dict, "remaining", (long)remaining);
  
      dict_add_number(dict, "repeat",
!                   (long)(timer->tr_repeat < 0 ? -1 : timer->tr_repeat + 1));
      dict_add_number(dict, "paused", (long)(timer->tr_paused));
  
      di = dictitem_alloc((char_u *)"callback");
--- 696,703 ----
      dict_add_number(dict, "remaining", (long)remaining);
  
      dict_add_number(dict, "repeat",
!           (long)(timer->tr_repeat < 0 ? -1
!                            : timer->tr_repeat + (timer->tr_firing ? 0 : 1)));
      dict_add_number(dict, "paused", (long)(timer->tr_paused));
  
      di = dictitem_alloc((char_u *)"callback");
*** ../vim-8.2.3767/src/testdir/test_timers.vim 2021-10-16 13:00:10.940165406 
+0100
--- src/testdir/test_timers.vim 2021-12-09 18:42:33.209983851 +0000
***************
*** 117,122 ****
--- 117,129 ----
    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})
+   sleep 100m
+   call assert_equal([2, 1, 0], g:timer_repeat)
+   unlet g:timer_repeat
  endfunc
  
  func Test_timer_stopall()
*** ../vim-8.2.3767/src/version.c       2021-12-09 17:43:53.847057125 +0000
--- src/version.c       2021-12-09 18:31:50.503903849 +0000
***************
*** 755,756 ****
--- 755,758 ----
  {   /* Add new patch number below this line */
+ /**/
+     3768,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
21. Your dog has its own home page.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211209184423.C8ADB1C0C20%40moolenaar.net.

Raspunde prin e-mail lui