0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.1.1625: script line numbers are not exactly right

Problem:    Script line numbers are not exactly right.
Solution:   Handle heredoc and continuation lines better. (Ozaki Kiichi,
            closes #4611, closes #4511)
This commit is contained in:
Bram Moolenaar
2019-07-04 14:57:12 +02:00
parent 0d702028fe
commit bc2cfe4672
5 changed files with 110 additions and 20 deletions

View File

@@ -2008,7 +2008,8 @@ ex_function(exarg_T *eap)
int todo;
hashitem_T *hi;
int do_concat = TRUE;
int sourcing_lnum_off;
linenr_T sourcing_lnum_off;
linenr_T sourcing_lnum_top;
/*
* ":function" without argument: list functions.
@@ -2275,6 +2276,9 @@ ex_function(exarg_T *eap)
cmdline_row = msg_row;
}
// Save the starting line number.
sourcing_lnum_top = sourcing_lnum;
indent = 2;
nesting = 0;
for (;;)
@@ -2285,7 +2289,6 @@ ex_function(exarg_T *eap)
saved_wait_return = FALSE;
}
need_wait_return = FALSE;
sourcing_lnum_off = sourcing_lnum;
if (line_arg != NULL)
{
@@ -2318,8 +2321,9 @@ ex_function(exarg_T *eap)
}
/* Detect line continuation: sourcing_lnum increased more than one. */
if (sourcing_lnum > sourcing_lnum_off + 1)
sourcing_lnum_off = sourcing_lnum - sourcing_lnum_off - 1;
sourcing_lnum_off = get_sourced_lnum(eap->getline, eap->cookie);
if (sourcing_lnum < sourcing_lnum_off)
sourcing_lnum_off -= sourcing_lnum;
else
sourcing_lnum_off = 0;
@@ -2670,7 +2674,7 @@ ex_function(exarg_T *eap)
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 - 1;
fp->uf_script_ctx.sc_lnum += sourcing_lnum_top;
goto ret_free;
erret: