Patch 9.0.0396
Problem:    :findrepl does not escape '&' and '~' properly.
Solution:   Escape depending on the value of 'magic'. (closes #11067)
Files:      src/gui.c, src/testdir/test_gui.vim


*** ../vim-9.0.0395/src/gui.c   2022-09-04 12:29:22.144893115 +0100
--- src/gui.c   2022-09-06 16:59:46.315063848 +0100
***************
*** 5360,5367 ****
      if (type == FRD_REPLACEALL)
      {
        ga_concat(&ga, (char_u *)"/");
!       // escape slash and backslash
!       p = vim_strsave_escaped(repl_text, (char_u *)"/\\");
        if (p != NULL)
            ga_concat(&ga, p);
        vim_free(p);
--- 5360,5369 ----
      if (type == FRD_REPLACEALL)
      {
        ga_concat(&ga, (char_u *)"/");
!       // Escape slash and backslash.
!       // Also escape tilde and ampersand if 'magic' is set.
!       p = vim_strsave_escaped(repl_text,
!                               p_magic ? (char_u *)"/\\~&" : (char_u *)"/\\");
        if (p != NULL)
            ga_concat(&ga, p);
        vim_free(p);
*** ../vim-9.0.0395/src/testdir/test_gui.vim    2022-09-02 21:55:45.503049444 
+0100
--- src/testdir/test_gui.vim    2022-09-06 16:52:34.483341197 +0100
***************
*** 1580,1585 ****
--- 1580,1591 ----
    call test_gui_event('findrepl', args)
    call assert_equal(['ONE two ONE', 'Twoo ONE two ONEo'], getline(1, '$'))
  
+   " Replace all instances with sub-replace specials
+   call cursor(1, 1)
+   let args = #{find_text: 'ONE', repl_text: '&~&', flags: 0x4, forward: 1}
+   call test_gui_event('findrepl', args)
+   call assert_equal(['&~& two &~&', 'Twoo &~& two &~&o'], getline(1, '$'))
+ 
    " Invalid arguments
    call assert_false(test_gui_event('findrepl', {}))
    let args = #{repl_text: 'a', flags: 1, forward: 1}
*** ../vim-9.0.0395/src/version.c       2022-09-06 16:31:22.380166840 +0100
--- src/version.c       2022-09-06 16:54:42.127259205 +0100
***************
*** 705,706 ****
--- 705,708 ----
  {   /* Add new patch number below this line */
+ /**/
+     396,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
16. You step out of your room and realize that your parents have moved and
    you don't have a clue when it happened.

 /// 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/20220906160052.67AB01C0CE4%40moolenaar.net.

Raspunde prin e-mail lui