Mercurial > vim
changeset 26203:a968027f8a2c v8.2.3633
patch 8.2.3633: Vim9: line number of lambda is off by one
Commit: https://github.com/vim/vim/commit/a755fdbe80bed4897e06028f0044c208e0f9d8cb
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Nov 20 21:35:41 2021 +0000
patch 8.2.3633: Vim9: line number of lambda is off by one
Problem: Vim9: line number of lambda is off by one.
Solution: Add one to the line number. (closes https://github.com/vim/vim/issues/9083)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 20 Nov 2021 22:45:03 +0100 |
parents | 72829db3aeaa |
children | b22360f54fad |
files | src/testdir/test_vim9_func.vim src/userfunc.c src/version.c |
diffstat | 3 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_func.vim +++ b/src/testdir/test_vim9_func.vim @@ -1052,6 +1052,20 @@ def Test_call_lambda_args() CheckScriptFailure(['vim9script'] + lines, 'E118: Too many arguments for function: <lambda>', 2) enddef +def Test_lambda_line_nr() + var lines =<< trim END + vim9script + # comment + # comment + var id = timer_start(1'000, (_) => 0) + var out = execute('verbose ' .. timer_info(id)[0].callback + ->string() + ->substitute("('\\|')", ' ', 'g')) + assert_match('Last set from .* line 4', out) + END + CheckScriptSuccess(lines) +enddef + def FilterWithCond(x: string, Cond: func(string): bool): bool return Cond(x) enddef
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -1491,7 +1491,7 @@ get_lambda_tv( fp->uf_flags = flags; fp->uf_calls = 0; fp->uf_script_ctx = current_sctx; - fp->uf_script_ctx.sc_lnum += SOURCING_LNUM - newlines.ga_len; + fp->uf_script_ctx.sc_lnum += SOURCING_LNUM - newlines.ga_len + 1; function_using_block_scopes(fp, evalarg->eval_cstack);