Patch 8.2.2694
Problem:    When 'matchpairs' is empty every character beeps. (Marco Hinz)
Solution:   Bail out when no character in 'matchpairs' was found.
            (closes #8053)  Add assert_nobeep().
Files:      runtime/doc/testing.txt, runtime/doc/eval.txt, src/search.c,
            src/testing.c, src/proto/testing.pro, src/evalfunc.c,
            src/testdir/test_textformat.vim


*** ../vim-8.2.2693/runtime/doc/testing.txt     2021-01-31 17:02:06.262490144 
+0100
--- runtime/doc/testing.txt     2021-04-02 18:17:49.892707001 +0200
***************
*** 242,248 ****
  assert_beeps({cmd})                                   *assert_beeps()*
                Run {cmd} and add an error message to |v:errors| if it does
                NOT produce a beep or visual bell.
!               Also see |assert_fails()| and |assert-return|.
  
                Can also be used as a |method|: >
                        GetCmd()->assert_beeps()
--- 243,250 ----
  assert_beeps({cmd})                                   *assert_beeps()*
                Run {cmd} and add an error message to |v:errors| if it does
                NOT produce a beep or visual bell.
!               Also see |assert_fails()|, |assert_nobeep()| and
!               |assert-return|.
  
                Can also be used as a |method|: >
                        GetCmd()->assert_beeps()
***************
*** 376,381 ****
--- 378,391 ----
                Can also be used as a |method|: >
                        getFile()->assert_match('foo.*')
  <
+ assert_nobeep({cmd})                                  *assert_nobeep()*
+               Run {cmd} and add an error message to |v:errors| if it
+               produces a beep or visual bell.
+               Also see |assert_beeps()|.
+ 
+               Can also be used as a |method|: >
+                       GetCmd()->assert_nobeep()
+ <
                                                        *assert_notequal()*
  assert_notequal({expected}, {actual} [, {msg}])
                The opposite of `assert_equal()`: add an error message to
*** ../vim-8.2.2693/runtime/doc/eval.txt        2021-03-26 20:41:24.769620626 
+0100
--- runtime/doc/eval.txt        2021-04-02 18:18:15.660645622 +0200
***************
*** 2440,2445 ****
--- 2443,2449 ----
                                Number  assert {actual} is inside the range
  assert_match({pat}, {text} [, {msg}])
                                Number  assert {pat} matches {text}
+ assert_nobeep({cmd})          Number  assert {cmd} does not cause a beep
  assert_notequal({exp}, {act} [, {msg}])
                                Number  assert {exp} is not equal {act}
  assert_notmatch({pat}, {text} [, {msg}])
*** ../vim-8.2.2693/src/search.c        2021-02-03 23:04:42.526462751 +0100
--- src/search.c        2021-04-02 18:53:19.038748352 +0200
***************
*** 2817,2822 ****
--- 2817,2824 ----
        if (*p == NUL)
            return;
      }
+     if (*p == NUL)
+       return;
  
      if ((lpos = findmatch(NULL, NUL)) == NULL)            // no match, so beep
        vim_beep(BO_MATCH);
*** ../vim-8.2.2693/src/testing.c       2021-03-10 21:26:34.152867581 +0100
--- src/testing.c       2021-04-02 18:15:46.309001368 +0200
***************
*** 338,344 ****
  }
  
      static int
! assert_beeps(typval_T *argvars)
  {
      char_u    *cmd = tv_get_string_chk(&argvars[0]);
      garray_T  ga;
--- 338,344 ----
  }
  
      static int
! assert_beeps(typval_T *argvars, int no_beep)
  {
      char_u    *cmd = tv_get_string_chk(&argvars[0]);
      garray_T  ga;
***************
*** 348,357 ****
      suppress_errthrow = TRUE;
      emsg_silent = FALSE;
      do_cmdline_cmd(cmd);
!     if (!called_vim_beep)
      {
        prepare_assert_error(&ga);
!       ga_concat(&ga, (char_u *)"command did not beep: ");
        ga_concat(&ga, cmd);
        assert_error(&ga);
        ga_clear(&ga);
--- 348,360 ----
      suppress_errthrow = TRUE;
      emsg_silent = FALSE;
      do_cmdline_cmd(cmd);
!     if (no_beep ? called_vim_beep : !called_vim_beep)
      {
        prepare_assert_error(&ga);
!       if (no_beep)
!           ga_concat(&ga, (char_u *)"command did beep: ");
!       else
!           ga_concat(&ga, (char_u *)"command did not beep: ");
        ga_concat(&ga, cmd);
        assert_error(&ga);
        ga_clear(&ga);
***************
*** 369,375 ****
      void
  f_assert_beeps(typval_T *argvars, typval_T *rettv)
  {
!     rettv->vval.v_number = assert_beeps(argvars);
  }
  
  /*
--- 372,387 ----
      void
  f_assert_beeps(typval_T *argvars, typval_T *rettv)
  {
!     rettv->vval.v_number = assert_beeps(argvars, FALSE);
! }
! 
! /*
!  * "assert_nobeep(cmd [, error])" function
!  */
!     void
! f_assert_nobeep(typval_T *argvars, typval_T *rettv)
! {
!     rettv->vval.v_number = assert_beeps(argvars, TRUE);
  }
  
  /*
*** ../vim-8.2.2693/src/proto/testing.pro       2020-04-01 22:10:56.432201238 
+0200
--- src/proto/testing.pro       2021-04-02 18:18:41.460584159 +0200
***************
*** 1,5 ****
--- 1,6 ----
  /* testing.c */
  void f_assert_beeps(typval_T *argvars, typval_T *rettv);
+ void f_assert_nobeep(typval_T *argvars, typval_T *rettv);
  void f_assert_equal(typval_T *argvars, typval_T *rettv);
  void f_assert_equalfile(typval_T *argvars, typval_T *rettv);
  void f_assert_notequal(typval_T *argvars, typval_T *rettv);
*** ../vim-8.2.2693/src/evalfunc.c      2021-03-27 21:23:27.064153032 +0100
--- src/evalfunc.c      2021-04-02 18:20:39.408303202 +0200
***************
*** 739,744 ****
--- 739,746 ----
                        ret_number_bool,    f_assert_inrange},
      {"assert_match",  2, 3, FEARG_2,      NULL,
                        ret_number_bool,    f_assert_match},
+     {"assert_nobeep", 1, 2, FEARG_1,      NULL,
+                       ret_number_bool,    f_assert_nobeep},
      {"assert_notequal",       2, 3, FEARG_2,      NULL,
                        ret_number_bool,    f_assert_notequal},
      {"assert_notmatch",       2, 3, FEARG_2,      NULL,
*** ../vim-8.2.2693/src/testdir/test_textformat.vim     2021-03-13 
13:14:00.810145346 +0100
--- src/testdir/test_textformat.vim     2021-04-02 18:48:59.363493419 +0200
***************
*** 858,863 ****
--- 858,871 ----
    close!
  endfunc
  
+ func Test_empty_matchpairs()
+   split
+   set matchpairs= showmatch
+   call assert_nobeep('call feedkeys("ax\tx\t\<Esc>", "xt")')
+   set matchpairs& noshowmatch
+   bwipe!
+ endfunc
+ 
  func Test_mps_error()
    let encoding_save = &encoding
  
*** ../vim-8.2.2693/src/version.c       2021-04-02 14:43:52.947178932 +0200
--- src/version.c       2021-04-02 18:53:37.034697868 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2694,
  /**/

-- 
"Oh, no!  NOT the Spanish Inquisition!"
"NOBODY expects the Spanish Inquisition!!!"
                                -- Monty Python sketch --
"Oh, no!  NOT another option!"
"EVERYBODY expects another option!!!"
                                -- Discussion in vim-dev mailing list --

 /// 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/202104021656.132GuxPb2283850%40masaka.moolenaar.net.

Raspunde prin e-mail lui