diff options
author | matveyt <matthewtarasov@yandex.ru> | 2022-09-06 17:00:15 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-09-06 17:00:15 +0100 |
commit | 2834ebdee473c838e50e60d0aa160f0e62fc8ef9 (patch) | |
tree | 3c5d2b3a0e3f0c261d5569e5eb96eb5eeec88349 | |
parent | 635bb4908577738c5658a95672259b8537d97d49 (diff) | |
download | vim-git-2834ebdee473c838e50e60d0aa160f0e62fc8ef9.tar.gz |
patch 9.0.0396: :findrepl does not escape '&' and '~' properlyv9.0.0396
Problem: :findrepl does not escape '&' and '~' properly.
Solution: Escape depending on the value of 'magic'. (closes #11067)
-rw-r--r-- | src/gui.c | 6 | ||||
-rw-r--r-- | src/testdir/test_gui.vim | 6 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 12 insertions, 2 deletions
@@ -5360,8 +5360,10 @@ gui_do_findrepl( if (type == FRD_REPLACEALL) { ga_concat(&ga, (char_u *)"/"); - // escape slash and backslash - p = vim_strsave_escaped(repl_text, (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); diff --git a/src/testdir/test_gui.vim b/src/testdir/test_gui.vim index 29e4ecdd5..a2491458d 100644 --- a/src/testdir/test_gui.vim +++ b/src/testdir/test_gui.vim @@ -1580,6 +1580,12 @@ func Test_gui_findrepl() 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} diff --git a/src/version.c b/src/version.c index 2cf848c63..f1170220c 100644 --- a/src/version.c +++ b/src/version.c @@ -704,6 +704,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 396, +/**/ 395, /**/ 394, |