0
0
mirror of https://github.com/vim/vim.git synced 2025-10-05 05:34:07 -04:00

patch 8.2.2784: Vim9: cannot use \=expr in :substitute

Problem:    Vim9: cannot use \=expr in :substitute.
Solution:   Compile the expression into instructions and execute them when
            invoked.
This commit is contained in:
Bram Moolenaar
2021-04-19 16:48:48 +02:00
parent e8209b91b9
commit 4c13721482
11 changed files with 1476 additions and 1185 deletions

View File

@@ -1172,5 +1172,27 @@ def Test_lockvar()
CheckDefFailure(lines, 'E1178', 2)
enddef
def Test_substitute_expr()
var to = 'repl'
new
setline(1, 'one from two')
s/from/\=to
assert_equal('one repl two', getline(1))
setline(1, 'one from two')
s/from/\=to .. '_x'
assert_equal('one repl_x two', getline(1))
setline(1, 'one from two from three')
var also = 'also'
s/from/\=to .. '_' .. also/g#e
assert_equal('one repl_also two repl_also three', getline(1))
CheckDefFailure(['s/from/\="x")/'], 'E488:')
CheckDefFailure(['s/from/\="x"/9'], 'E488:')
bwipe!
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker