mirror of
https://github.com/vim/vim.git
synced 2025-10-02 05:04:20 -04:00
patch 7.4.2072
Problem: substitute() does not support a Funcref argument. Solution: Support a Funcref like it supports a string starting with "\=".
This commit is contained in:
@@ -135,3 +135,21 @@ function Test_printf_64bit()
|
||||
call assert_equal("123456789012345", printf('%d', 123456789012345))
|
||||
endif
|
||||
endfunc
|
||||
|
||||
func Test_substitute_expr()
|
||||
let g:val = 'XXX'
|
||||
call assert_equal('XXX', substitute('yyy', 'y*', '\=g:val', ''))
|
||||
call assert_equal('XXX', substitute('yyy', 'y*', {-> g:val}, ''))
|
||||
call assert_equal("-\u1b \uf2-", substitute("-%1b %f2-", '%\(\x\x\)',
|
||||
\ '\=nr2char("0x" . submatch(1))', 'g'))
|
||||
call assert_equal("-\u1b \uf2-", substitute("-%1b %f2-", '%\(\x\x\)',
|
||||
\ {-> nr2char("0x" . submatch(1))}, 'g'))
|
||||
|
||||
call assert_equal('231', substitute('123', '\(.\)\(.\)\(.\)',
|
||||
\ {-> submatch(2) . submatch(3) . submatch(1)}, ''))
|
||||
|
||||
func Recurse()
|
||||
return substitute('yyy', 'y*', {-> g:val}, '')
|
||||
endfunc
|
||||
call assert_equal('--', substitute('xxx', 'x*', {-> '-' . Recurse() . '-'}, ''))
|
||||
endfunc
|
||||
|
Reference in New Issue
Block a user