Mercurial > vim
diff src/testdir/test_substitute.vim @ 18572:23fef64352a1 v8.1.2280
patch 8.1.2280: crash when passing partial to substitute()
Commit: https://github.com/vim/vim/commit/b0745b221d284e381f1bd4b591cd68ea54b6a51d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 9 22:28:11 2019 +0100
patch 8.1.2280: crash when passing partial to substitute()
Problem: Crash when passing partial to substitute().
Solution: Take extra arguments into account. (closes https://github.com/vim/vim/issues/5186)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 09 Nov 2019 22:30:04 +0100 |
parents | 54e5fa1f9cfc |
children | e9675870c480 |
line wrap: on
line diff
--- a/src/testdir/test_substitute.vim +++ b/src/testdir/test_substitute.vim @@ -405,6 +405,14 @@ func Test_sub_replace_10() call assert_equal('1aaa', substitute('123', '1\zs\|[23]', 'a', 'g')) endfunc +func SubReplacer(text, submatches) + return a:text .. a:submatches[0] .. a:text +endfunc + +func Test_substitute_partial() + call assert_equal('1foo2foo3', substitute('123', '2', function('SubReplacer', ['foo']), 'g')) +endfunc + " Tests for *sub-replace-special* and *sub-replace-expression* on :substitute. " Execute a list of :substitute command tests