summaryrefslogtreecommitdiffstats
path: root/src/highlight.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-09-18 19:40:45 +0200
committerBram Moolenaar <Bram@vim.org>2020-09-18 19:40:45 +0200
commite8df0104985af58ee501a6fbac8ac9f886e84e5a (patch)
tree9502868deb49b4aab66db76fdb5008e6cc218b5f /src/highlight.c
parent77e5dcc36a82da040072d74e3ced410d15c42757 (diff)
patch 8.2.1705: "verbose hi Name" reports incorrect info after ":hi clear"v8.2.1705
Problem: "verbose hi Name" reports incorrect info after ":hi clear". Solution: Store the script context. (Antony Scriven, closes #6975)
Diffstat (limited to 'src/highlight.c')
-rw-r--r--src/highlight.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/highlight.c b/src/highlight.c
index 85745024cc..0a014473b1 100644
--- a/src/highlight.c
+++ b/src/highlight.c
@@ -76,6 +76,7 @@ typedef struct
int sg_deflink; // default link; restored in highlight_clear()
int sg_set; // combination of SG_* flags
#ifdef FEAT_EVAL
+ sctx_T sg_deflink_sctx; // script where the default link was set
sctx_T sg_script_ctx; // script in which the group was last set
#endif
} hl_group_T;
@@ -746,7 +747,13 @@ do_highlight(
{
hlgroup = &HL_TABLE()[from_id - 1];
if (dodefault && (forceit || hlgroup->sg_deflink == 0))
+ {
hlgroup->sg_deflink = to_id;
+#ifdef FEAT_EVAL
+ hlgroup->sg_deflink_sctx = current_sctx;
+ hlgroup->sg_deflink_sctx.sc_lnum += SOURCING_LNUM;
+#endif
+ }
}
if (from_id > 0 && (!init || hlgroup->sg_set == 0))
@@ -1691,16 +1698,12 @@ highlight_clear(int idx)
VIM_CLEAR(HL_TABLE()[idx].sg_font_name);
HL_TABLE()[idx].sg_gui_attr = 0;
#endif
-#ifdef FEAT_EVAL
- // Restore any default link.
+ // Restore default link and context if they exist. Otherwise clears.
HL_TABLE()[idx].sg_link = HL_TABLE()[idx].sg_deflink;
- // 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_script_ctx.sc_sid = 0;
- HL_TABLE()[idx].sg_script_ctx.sc_lnum = 0;
- }
+#ifdef FEAT_EVAL
+ // Since we set the default link, set the location to where the default
+ // link was set.
+ HL_TABLE()[idx].sg_script_ctx = HL_TABLE()[idx].sg_deflink_sctx;
#endif
}