mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.0396: :findrepl does not escape '&' and '~' properly
Problem: :findrepl does not escape '&' and '~' properly. Solution: Escape depending on the value of 'magic'. (closes #11067)
This commit is contained in:
parent
635bb49085
commit
2834ebdee4
@ -5360,8 +5360,10 @@ gui_do_findrepl(
|
|||||||
if (type == FRD_REPLACEALL)
|
if (type == FRD_REPLACEALL)
|
||||||
{
|
{
|
||||||
ga_concat(&ga, (char_u *)"/");
|
ga_concat(&ga, (char_u *)"/");
|
||||||
// escape slash and backslash
|
// Escape slash and backslash.
|
||||||
p = vim_strsave_escaped(repl_text, (char_u *)"/\\");
|
// Also escape tilde and ampersand if 'magic' is set.
|
||||||
|
p = vim_strsave_escaped(repl_text,
|
||||||
|
p_magic ? (char_u *)"/\\~&" : (char_u *)"/\\");
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
ga_concat(&ga, p);
|
ga_concat(&ga, p);
|
||||||
vim_free(p);
|
vim_free(p);
|
||||||
|
@ -1580,6 +1580,12 @@ func Test_gui_findrepl()
|
|||||||
call test_gui_event('findrepl', args)
|
call test_gui_event('findrepl', args)
|
||||||
call assert_equal(['ONE two ONE', 'Twoo ONE two ONEo'], getline(1, '$'))
|
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
|
" Invalid arguments
|
||||||
call assert_false(test_gui_event('findrepl', {}))
|
call assert_false(test_gui_event('findrepl', {}))
|
||||||
let args = #{repl_text: 'a', flags: 1, forward: 1}
|
let args = #{repl_text: 'a', flags: 1, forward: 1}
|
||||||
|
@ -703,6 +703,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
396,
|
||||||
/**/
|
/**/
|
||||||
395,
|
395,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user