summaryrefslogtreecommitdiffstats
path: root/src/vim9execute.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-06-16 22:24:40 +0200
committerBram Moolenaar <Bram@vim.org>2021-06-16 22:24:40 +0200
commit4cea536bdf48df459e7ad651dfee006844bbf2c0 (patch)
tree3ff2e149ad2a9d6386d93938e0e14f0969f84221 /src/vim9execute.c
parent29f0dc3689eafcf7888e06d57d1cf79e62c5c148 (diff)
patch 8.2.3013: Vim: when debugging only first line of command is displayedv8.2.3013
Problem: Vim: when debugging only the first line of a command using line continuation is displayed. Solution: Find the next command and concatenate lines until that one. (closes #8392)
Diffstat (limited to 'src/vim9execute.c')
-rw-r--r--src/vim9execute.c62
1 files changed, 47 insertions, 15 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c
index bbcf7ffc3c..33e9244245 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -1433,6 +1433,52 @@ lookup_debug_var(char_u *name)
return NULL;
}
+ static void
+handle_debug(isn_T *iptr, ectx_T *ectx)
+{
+ char_u *line;
+ ufunc_T *ufunc = (((dfunc_T *)def_functions.ga_data)
+ + ectx->ec_dfunc_idx)->df_ufunc;
+ isn_T *ni;
+ int end_lnum = iptr->isn_lnum;
+ garray_T ga;
+ int lnum;
+
+ SOURCING_LNUM = iptr->isn_lnum;
+ debug_context = ectx;
+ debug_var_count = iptr->isn_arg.number;
+
+ for (ni = iptr + 1; ni->isn_type != ISN_FINISH; ++ni)
+ if (ni->isn_type == ISN_DEBUG
+ || ni->isn_type == ISN_RETURN
+ || ni->isn_type == ISN_RETURN_VOID)
+ {
+ end_lnum = ni->isn_lnum;
+ break;
+ }
+
+ if (end_lnum > iptr->isn_lnum)
+ {
+ ga_init2(&ga, sizeof(char_u *), 10);
+ for (lnum = iptr->isn_lnum; lnum < end_lnum; ++lnum)
+ if (ga_grow(&ga, 1) == OK)
+ ((char_u **)(ga.ga_data))[ga.ga_len++] =
+ skipwhite(((char_u **)ufunc->uf_lines.ga_data)[lnum - 1]);
+ line = ga_concat_strings(&ga, " ");
+ vim_free(ga.ga_data);
+ }
+ else
+ line = ((char_u **)ufunc->uf_lines.ga_data)[iptr->isn_lnum - 1];
+ if (line == NULL)
+ line = (char_u *)"[empty]";
+
+ do_debug(line);
+ debug_context = NULL;
+
+ if (end_lnum > iptr->isn_lnum)
+ vim_free(line);
+}
+
/*
* Execute instructions in execution context "ectx".
* Return OK or FAIL;
@@ -4156,21 +4202,7 @@ exec_instructions(ectx_T *ectx)
case ISN_DEBUG:
if (ex_nesting_level <= debug_break_level)
- {
- char_u *line;
- ufunc_T *ufunc = (((dfunc_T *)def_functions.ga_data)
- + ectx->ec_dfunc_idx)->df_ufunc;
-
- SOURCING_LNUM = iptr->isn_lnum;
- debug_context = ectx;
- debug_var_count = iptr->isn_arg.number;
- line = ((char_u **)ufunc->uf_lines.ga_data)[
- iptr->isn_lnum - 1];
- if (line == NULL)
- line = (char_u *)"[empty]";
- do_debug(line);
- debug_context = NULL;
- }
+ handle_debug(iptr, ectx);
break;
case ISN_SHUFFLE: