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

patch 8.2.2775: Vim9: wrong line number used for some commands

Problem:    Vim9: wrong line number used for some commands.
Solution:   For :exe, :echo and the like use the line number of the start of
            the command.  When calling a function set the line number in the
            script context.
This commit is contained in:
Bram Moolenaar
2021-04-17 17:59:19 +02:00
parent 6c7cc347af
commit c70fe460b0
5 changed files with 46 additions and 5 deletions

View File

@@ -3848,6 +3848,37 @@ def Test_unsupported_commands()
CheckScriptFailure(['vim9script'] + lines, 'E1100:')
enddef
def Test_mapping_line_number()
var lines =<< trim END
vim9script
def g:FuncA()
# Some comment
FuncB(0)
enddef
# Some comment
def FuncB(
# Some comment
n: number
)
exe 'nno '
# Some comment
.. '<F3> a'
.. 'b'
.. 'c'
enddef
END
CheckScriptSuccess(lines)
var res = execute('verbose nmap <F3>')
assert_match('No mapping found', res)
g:FuncA()
res = execute('verbose nmap <F3>')
assert_match(' <F3> .* abc.*Last set from .*XScriptSuccess\d\+ line 11', res)
nunmap <F3>
delfunc g:FuncA
enddef
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new