Patch 8.2.4506
Problem:    "pattern not found" for :global is not an error message.
Solution:   In Vim9 script make this an actual error, so that try/catch can be
            used as expected.
Files:      src/ex_cmds.c, src/errors.h, src/testdir/test_global.vim


*** ../vim-8.2.4505/src/ex_cmds.c       2022-02-03 13:05:28.809273683 +0000
--- src/ex_cmds.c       2022-03-04 21:25:25.627877446 +0000
***************
*** 5001,5009 ****
        else if (ndone == 0)
        {
            if (type == 'v')
!               smsg(_("Pattern found in every line: %s"), pat);
            else
!               smsg(_("Pattern not found: %s"), pat);
        }
        else
        {
--- 5001,5019 ----
        else if (ndone == 0)
        {
            if (type == 'v')
!           {
!               if (in_vim9script())
!                   semsg(_(e_pattern_found_in_every_line_str), pat);
!               else
!                   smsg(_("Pattern found in every line: %s"), pat);
!           }
            else
!           {
!               if (in_vim9script())
!                   semsg(_(e_pattern_not_found_str), pat);
!               else
!                   smsg(_("Pattern not found: %s"), pat);
!           }
        }
        else
        {
*** ../vim-8.2.4505/src/errors.h        2022-03-04 20:10:33.400917886 +0000
--- src/errors.h        2022-03-04 21:25:13.467916782 +0000
***************
*** 1346,1352 ****
  EXTERN char e_commentstring_must_be_empty_or_contain_str[]
        INIT(= N_("E537: 'commentstring' must be empty or contain %s"));
  #endif
! // E538 unused
  EXTERN char e_illegal_character_str[]
        INIT(= N_("E539: Illegal character <%s>"));
  #ifdef FEAT_STL_OPT
--- 1346,1353 ----
  EXTERN char e_commentstring_must_be_empty_or_contain_str[]
        INIT(= N_("E537: 'commentstring' must be empty or contain %s"));
  #endif
! EXTERN char e_pattern_found_in_every_line_str[]
!       INIT(= N_("E538: Pattern found in every line: %s"));
  EXTERN char e_illegal_character_str[]
        INIT(= N_("E539: Illegal character <%s>"));
  #ifdef FEAT_STL_OPT
*** ../vim-8.2.4505/src/testdir/test_global.vim 2021-06-21 20:55:14.696257282 
+0100
--- src/testdir/test_global.vim 2022-03-04 21:31:43.558815316 +0000
***************
*** 68,73 ****
--- 68,93 ----
    v/foo\|bar/p
    call assert_notequal('', v:statusmsg)
  
+   " In Vim9 script this is an error
+   let caught = 'no'
+   try
+     vim9cmd v/foo\|bar/p
+   catch /E538/
+     let caught = 'yes'
+     call assert_match('E538: Pattern found in every line: foo\|bar', 
v:exception)
+   endtry
+   call assert_equal('yes', caught)
+ 
+   " In Vim9 script not matching is an error
+   let caught = 'no'
+   try
+     vim9cmd g/foobarnotfound/p
+   catch /E486/
+     let caught = 'yes'
+     call assert_match('E486: Pattern not found: foobarnotfound', v:exception)
+   endtry
+   call assert_equal('yes', caught)
+ 
    close!
  endfunc
  
*** ../vim-8.2.4505/src/version.c       2022-03-04 20:10:33.404917902 +0000
--- src/version.c       2022-03-04 21:25:53.959787321 +0000
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     4506,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
168. You have your own domain name.

 /// 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/20220304213505.D7EF21C00F6%40moolenaar.net.

Raspunde prin e-mail lui