Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
24470:9e75cdb46bc5 | 24471:baf75c8e1b7b |
---|---|
3846 END | 3846 END |
3847 CheckDefFailure(lines, 'E1100:') | 3847 CheckDefFailure(lines, 'E1100:') |
3848 CheckScriptFailure(['vim9script'] + lines, 'E1100:') | 3848 CheckScriptFailure(['vim9script'] + lines, 'E1100:') |
3849 enddef | 3849 enddef |
3850 | 3850 |
3851 def Test_mapping_line_number() | |
3852 var lines =<< trim END | |
3853 vim9script | |
3854 def g:FuncA() | |
3855 # Some comment | |
3856 FuncB(0) | |
3857 enddef | |
3858 # Some comment | |
3859 def FuncB( | |
3860 # Some comment | |
3861 n: number | |
3862 ) | |
3863 exe 'nno ' | |
3864 # Some comment | |
3865 .. '<F3> a' | |
3866 .. 'b' | |
3867 .. 'c' | |
3868 enddef | |
3869 END | |
3870 CheckScriptSuccess(lines) | |
3871 var res = execute('verbose nmap <F3>') | |
3872 assert_match('No mapping found', res) | |
3873 | |
3874 g:FuncA() | |
3875 res = execute('verbose nmap <F3>') | |
3876 assert_match(' <F3> .* abc.*Last set from .*XScriptSuccess\d\+ line 11', res) | |
3877 | |
3878 nunmap <F3> | |
3879 delfunc g:FuncA | |
3880 enddef | |
3881 | |
3851 " Keep this last, it messes up highlighting. | 3882 " Keep this last, it messes up highlighting. |
3852 def Test_substitute_cmd() | 3883 def Test_substitute_cmd() |
3853 new | 3884 new |
3854 setline(1, 'something') | 3885 setline(1, 'something') |
3855 :substitute(some(other( | 3886 :substitute(some(other( |