Mercurial > vim
diff src/testdir/test_substitute.vim @ 22143:3ec9e302ec94 v8.2.1621
patch 8.2.1621: crash when using submatch(0, 1) in substitute()
Commit: https://github.com/vim/vim/commit/8a0dcf43305586853f452a77fa295b0c8d54b463
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 6 15:14:45 2020 +0200
patch 8.2.1621: crash when using submatch(0, 1) in substitute()
Problem: Crash when using submatch(0, 1) in substitute().
Solution: Increment reference count. (closes https://github.com/vim/vim/issues/6887)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 06 Sep 2020 15:15:04 +0200 |
parents | ff21e2962490 |
children | 595ea7f099cd |
line wrap: on
line diff
--- a/src/testdir/test_substitute.vim +++ b/src/testdir/test_substitute.vim @@ -881,6 +881,12 @@ func Test_invalid_submatch() call assert_equal([], submatch(1, 1)) endfunc +func Test_submatch_list_concatenate() + let pat = 'A\(.\)' + let Rep = {-> string([submatch(0, 1)] + [[submatch(1)]])} + call substitute('A1', pat, Rep, '')->assert_equal("[['A1'], ['1']]") +endfunc + func Test_substitute_expr_arg() call assert_equal('123456789-123456789=', substitute('123456789', \ '\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)\(.\)',