Patch 8.2.5102
Problem:    Interrupt not caught in test.
Solution:   Consider an exception thrown in the current try/catch when got_int
            is set.  Also catch early exit when not using try/catch.
Files:      src/indent.c, src/testing.c, src/testdir/test_retab.vim,
            src/testdir/runtest.vim


*** ../vim-8.2.5101/src/indent.c        2022-06-12 21:10:52.360714654 +0100
--- src/indent.c        2022-06-15 20:30:47.608417130 +0100
***************
*** 1781,1788 ****
            if (vcol >= MAXCOL)
            {
                emsg(_(e_resulting_text_too_long));
!               // set got_int to break out of any loop
!               got_int = TRUE;
                break;
            }
            if (has_mbyte)
--- 1781,1790 ----
            if (vcol >= MAXCOL)
            {
                emsg(_(e_resulting_text_too_long));
!               // when not inside a try/catch set got_int to break out of any
!               // loop
!               if (trylevel == 0)
!                   got_int = TRUE;
                break;
            }
            if (has_mbyte)
*** ../vim-8.2.5101/src/testing.c       2022-05-16 15:27:41.577581374 +0100
--- src/testing.c       2022-06-15 20:46:17.194425196 +0100
***************
*** 742,747 ****
--- 742,748 ----
      suppress_errthrow = FALSE;
      in_assert_fails = FALSE;
      did_emsg = FALSE;
+     got_int = FALSE;
      msg_col = 0;
      need_wait_return = FALSE;
      emsg_on_display = FALSE;
*** ../vim-8.2.5101/src/testdir/test_retab.vim  2022-06-12 23:05:02.452989640 
+0100
--- src/testdir/test_retab.vim  2022-06-15 20:48:04.086251055 +0100
***************
*** 82,101 ****
    call assert_fails('ret 80000000000000000000', 'E475:')
  endfunc
  
! " FIXME: the try/catch does not catch the interrupt
! func FIXME_Test_retab_endless()
    new
    call setline(1, "\t0\t")
    let caught = 'no'
    try
!     while 1
!       set ts=4000
!       retab 4
!     endwhile
!   catch
      let caught = v:exception
    endtry
!   call assert_notequal('no', caught)
    bwipe!
    set tabstop&
  endfunc
--- 82,115 ----
    call assert_fails('ret 80000000000000000000', 'E475:')
  endfunc
  
! func RetabLoop()
!   while 1
!     set ts=4000
!     retab 4
!   endwhile
! endfunc
! 
! func Test_retab_endless()
!   " inside try/catch we catch the error message
    new
    call setline(1, "\t0\t")
    let caught = 'no'
    try
!     call RetabLoop()
!   catch /E1240:/
      let caught = v:exception
    endtry
!   call assert_match('E1240:', caught)
!   bwipe!
!   set tabstop&
! endfunc
! 
! func Test_nocatch_retab_endless()
!   " not inside try/catch an interrupt is generated to get out of loops
!   new
!   call setline(1, "\t0\t")
!   call assert_fails('call RetabLoop()', ['E1240:', 'Interrupted'])
! 
    bwipe!
    set tabstop&
  endfunc
*** ../vim-8.2.5101/src/testdir/runtest.vim     2022-06-14 17:13:55.543974165 
+0100
--- src/testdir/runtest.vim     2022-06-15 18:59:52.261951286 +0100
***************
*** 201,206 ****
--- 201,207 ----
      endtry
    endif
  
+   au VimLeavePre * call EarlyExit(g:testfunc)
    if a:test =~ 'Test_nocatch_'
      " Function handles errors itself.  This avoids skipping commands after the
      " error.
***************
*** 212,220 ****
      endif
    else
      try
-       au VimLeavePre * call EarlyExit(g:testfunc)
        exe 'call ' . a:test
-       au! VimLeavePre
      catch /^\cskipped/
        call add(s:messages, '    Skipped')
        call add(s:skipped, 'SKIPPED ' . a:test . ': ' . 
substitute(v:exception, '^\S*\s\+', '',  ''))
--- 213,219 ----
***************
*** 222,227 ****
--- 221,227 ----
        call add(v:errors, 'Caught exception in ' . a:test . ': ' . v:exception 
. ' @ ' . v:throwpoint)
      endtry
    endif
+   au! VimLeavePre
  
    " In case 'insertmode' was set and something went wrong, make sure it is
    " reset to avoid trouble with anything else.
*** ../vim-8.2.5101/src/version.c       2022-06-15 18:31:41.949566497 +0100
--- src/version.c       2022-06-15 19:00:37.933949652 +0100
***************
*** 736,737 ****
--- 736,739 ----
  {   /* Add new patch number below this line */
+ /**/
+     5102,
  /**/

-- 
Communication is one of the most compli..., eh, well, it's hard.
You know what I mean.  Not?

 /// 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/20220615195005.624141C233D%40moolenaar.net.

Raspunde prin e-mail lui