patch 8.1.2280: crash when passing partial to substitute()
Problem: Crash when passing partial to substitute().
Solution: Take extra arguments into account. (closes #5186)
diff --git a/src/testdir/test_substitute.vim b/src/testdir/test_substitute.vim
index e8b0e49..b30464f 100644
--- a/src/testdir/test_substitute.vim
+++ b/src/testdir/test_substitute.vim
@@ -405,6 +405,14 @@
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