Mercurial > vim
diff src/vim9compile.c @ 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 | f0a3adf16f01 |
children | 96905804bf5a |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -8221,6 +8221,7 @@ compile_mult_expr(char_u *arg, int cmdid char_u *p = arg; char_u *prev = arg; int count = 0; + int start_ctx_lnum = cctx->ctx_lnum; for (;;) { @@ -8235,6 +8236,11 @@ compile_mult_expr(char_u *arg, int cmdid if (count > 0) { + long save_lnum = cctx->ctx_lnum; + + // Use the line number where the command started. + cctx->ctx_lnum = start_ctx_lnum; + if (cmdidx == CMD_echo || cmdidx == CMD_echon) generate_ECHO(cctx, cmdidx == CMD_echo, count); else if (cmdidx == CMD_execute) @@ -8243,6 +8249,8 @@ compile_mult_expr(char_u *arg, int cmdid generate_MULT_EXPR(cctx, ISN_ECHOMSG, count); else generate_MULT_EXPR(cctx, ISN_ECHOERR, count); + + cctx->ctx_lnum = save_lnum; } return p; }