comparison 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
comparison
equal deleted inserted replaced
24470:9e75cdb46bc5 24471:baf75c8e1b7b
8219 compile_mult_expr(char_u *arg, int cmdidx, cctx_T *cctx) 8219 compile_mult_expr(char_u *arg, int cmdidx, cctx_T *cctx)
8220 { 8220 {
8221 char_u *p = arg; 8221 char_u *p = arg;
8222 char_u *prev = arg; 8222 char_u *prev = arg;
8223 int count = 0; 8223 int count = 0;
8224 int start_ctx_lnum = cctx->ctx_lnum;
8224 8225
8225 for (;;) 8226 for (;;)
8226 { 8227 {
8227 if (ends_excmd2(prev, p)) 8228 if (ends_excmd2(prev, p))
8228 break; 8229 break;
8233 p = skipwhite(p); 8234 p = skipwhite(p);
8234 } 8235 }
8235 8236
8236 if (count > 0) 8237 if (count > 0)
8237 { 8238 {
8239 long save_lnum = cctx->ctx_lnum;
8240
8241 // Use the line number where the command started.
8242 cctx->ctx_lnum = start_ctx_lnum;
8243
8238 if (cmdidx == CMD_echo || cmdidx == CMD_echon) 8244 if (cmdidx == CMD_echo || cmdidx == CMD_echon)
8239 generate_ECHO(cctx, cmdidx == CMD_echo, count); 8245 generate_ECHO(cctx, cmdidx == CMD_echo, count);
8240 else if (cmdidx == CMD_execute) 8246 else if (cmdidx == CMD_execute)
8241 generate_MULT_EXPR(cctx, ISN_EXECUTE, count); 8247 generate_MULT_EXPR(cctx, ISN_EXECUTE, count);
8242 else if (cmdidx == CMD_echomsg) 8248 else if (cmdidx == CMD_echomsg)
8243 generate_MULT_EXPR(cctx, ISN_ECHOMSG, count); 8249 generate_MULT_EXPR(cctx, ISN_ECHOMSG, count);
8244 else 8250 else
8245 generate_MULT_EXPR(cctx, ISN_ECHOERR, count); 8251 generate_MULT_EXPR(cctx, ISN_ECHOERR, count);
8252
8253 cctx->ctx_lnum = save_lnum;
8246 } 8254 }
8247 return p; 8255 return p;
8248 } 8256 }
8249 8257
8250 /* 8258 /*