vim-patch:8.1.0362: cannot get the script line number when executing a function

Problem:    Cannot get the script line number when executing a function.
Solution:   Store the line number besides the script ID. (Ozaki Kiichi,
            closes vim/vim#3362)  Also display the line number with ":verbose set".
f29c1c6aa3
This commit is contained in:
erw7
2019-08-25 13:45:45 +09:00
parent 38806f23ed
commit a2e48b556b
24 changed files with 342 additions and 197 deletions

View File

@@ -60,7 +60,7 @@ struct hl_group {
int sg_attr; ///< Screen attr @see ATTR_ENTRY
int sg_link; ///< link to this highlight group ID
int sg_set; ///< combination of flags in \ref SG_SET
scid_T sg_scriptID; ///< script in which the group was last set
sctx_T sg_script_ctx; ///< script in which the group was last set
// for terminal UIs
int sg_cterm; ///< "cterm=" highlighting attr
///< (combination of \ref HlAttrFlags)
@@ -6565,13 +6565,15 @@ void do_highlight(const char *line, const bool forceit, const bool init)
EMSG(_("E414: group has settings, highlight link ignored"));
}
} else if (HL_TABLE()[from_id - 1].sg_link != to_id
|| HL_TABLE()[from_id - 1].sg_scriptID != current_SID
|| HL_TABLE()[from_id - 1].sg_script_ctx.sc_sid
!= current_sctx.sc_sid
|| HL_TABLE()[from_id - 1].sg_cleared) {
if (!init) {
HL_TABLE()[from_id - 1].sg_set |= SG_LINK;
}
HL_TABLE()[from_id - 1].sg_link = to_id;
HL_TABLE()[from_id - 1].sg_scriptID = current_SID;
HL_TABLE()[from_id - 1].sg_script_ctx = current_sctx;
HL_TABLE()[from_id - 1].sg_script_ctx.sc_lnum += sourcing_lnum;
HL_TABLE()[from_id - 1].sg_cleared = false;
redraw_all_later(SOME_VALID);
@@ -6950,7 +6952,8 @@ void do_highlight(const char *line, const bool forceit, const bool init)
} else {
set_hl_attr(idx);
}
HL_TABLE()[idx].sg_scriptID = current_SID;
HL_TABLE()[idx].sg_script_ctx = current_sctx;
HL_TABLE()[idx].sg_script_ctx.sc_lnum += sourcing_lnum;
}
xfree(key);
xfree(arg);
@@ -7034,7 +7037,8 @@ static void highlight_clear(int idx)
// Clear the script ID only when there is no link, since that is not
// cleared.
if (HL_TABLE()[idx].sg_link == 0) {
HL_TABLE()[idx].sg_scriptID = 0;
HL_TABLE()[idx].sg_script_ctx.sc_sid = 0;
HL_TABLE()[idx].sg_script_ctx.sc_lnum = 0;
}
}
@@ -7084,8 +7088,9 @@ static void highlight_list_one(const int id)
if (!didh)
highlight_list_arg(id, didh, LIST_STRING, 0, (char_u *)"cleared", "");
if (p_verbose > 0)
last_set_msg(sgp->sg_scriptID);
if (p_verbose > 0) {
last_set_msg(sgp->sg_script_ctx);
}
}
/// Outputs a highlight when doing ":hi MyHighlight"