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:
@@ -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:
|
||||
|
Reference in New Issue
Block a user