Mercurial > vim
diff src/testdir/test_vim9_script.vim @ 24471:baf75c8e1b7b v8.2.2775
patch 8.2.2775: Vim9: wrong line number used for some commands
Commit: https://github.com/vim/vim/commit/c70fe460b09f6182a13e4385f3232df4fdcd0741
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 17 17:59:19 2021 +0200
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 17 Apr 2021 18:00:04 +0200 |
parents | e5db23a8ad98 |
children | 83877a1b66fd |
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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