Mercurial > vim
diff src/vim9compile.c @ 25098:765a642e0e20 v8.2.3086
patch 8.2.3086: Vim9: breakpoint on "for" does not work
Commit: https://github.com/vim/vim/commit/6fc016168249360f0524b68f72cf33efd0574d40
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jul 3 13:36:31 2021 +0200
patch 8.2.3086: Vim9: breakpoint on "for" does not work
Problem: Vim9: breakpoint on "for" does not work.
Solution: Use the right line number in ISN_DEBUG. (closes https://github.com/vim/vim/issues/8486)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 03 Jul 2021 13:45:04 +0200 |
parents | 5c7a09cf97a1 |
children | de29f9a76233 |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -7747,6 +7747,7 @@ compile_for(char_u *arg_start, cctx_T *c type_T *vartype; type_T *item_type = &t_any; int idx; + int prev_lnum = cctx->ctx_prev_lnum; p = skip_var_list(arg_start, TRUE, &var_count, &semicolon, FALSE); if (p == NULL) @@ -7774,7 +7775,11 @@ compile_for(char_u *arg_start, cctx_T *c if (cctx->ctx_compile_type == CT_DEBUG && instr->ga_len > 0 && ((isn_T *)instr->ga_data)[instr->ga_len - 1] .isn_type == ISN_DEBUG) + { --instr->ga_len; + prev_lnum = ((isn_T *)instr->ga_data)[instr->ga_len] + .isn_arg.debug.dbg_break_lnum; + } scope = new_scope(cctx, FOR_SCOPE); if (scope == NULL) @@ -7934,8 +7939,15 @@ compile_for(char_u *arg_start, cctx_T *c } if (cctx->ctx_compile_type == CT_DEBUG) + { + int save_prev_lnum = cctx->ctx_prev_lnum; + // Add ISN_DEBUG here, so that the loop variables can be inspected. + // Use the prev_lnum from the ISN_DEBUG instruction removed above. + cctx->ctx_prev_lnum = prev_lnum; generate_instr_debug(cctx); + cctx->ctx_prev_lnum = save_prev_lnum; + } return arg_end;