vim-patch:9.1.0438: Wrong Ex command executed when :g uses '?' as delimiter (#28956)

Problem:  Wrong Ex command executed when :g uses '?' as delimiter and
          pattern contains escaped '?'.
Solution: Don't use "*newp" when it's not allocated (zeertzjq).

closes: vim/vim#14837

3074137542
This commit is contained in:
zeertzjq
2024-05-24 15:04:33 +08:00
committed by GitHub
parent 521b9930b8
commit c836383d21
3 changed files with 18 additions and 5 deletions

View File

@@ -96,7 +96,16 @@ func Test_global_newline()
close!
endfunc
func Test_wrong_delimiter()
" Test :g with ? as delimiter.
func Test_global_question_delimiter()
new
call setline(1, ['aaaaa', 'b?bbb', 'ccccc', 'ddd?d', 'eeeee'])
g?\??delete
call assert_equal(['aaaaa', 'ccccc', 'eeeee'], getline(1, '$'))
bwipe!
endfunc
func Test_global_wrong_delimiter()
call assert_fails('g x^bxd', 'E146:')
endfunc

View File

@@ -174,8 +174,8 @@ func Test_substitute_repeat()
bwipe!
endfunc
" Test :s with ? as separator.
func Test_substitute_question_separator()
" Test :s with ? as delimiter.
func Test_substitute_question_delimiter()
new
call setline(1, '??:??')
%s?\?\??!!?g