refactor(highlight): get rid of syn_unadd_group()

This is a sham. if the user does

  hi ExistingGroup guifg=AliceBlue invalidkey=foobar

the "guifg" part will still be executed. No need to micro-manage
the same case where ANewGroup is added instead.
This commit is contained in:
bfredl
2022-06-21 12:33:46 +02:00
parent 374e0b6678
commit ce7d18f86a

View File

@@ -1249,10 +1249,6 @@ void do_highlight(const char *line, const bool forceit, const bool init)
}
}
// If there is an error, and it's a new entry, remove it from the table.
if (error && idx == highlight_ga.ga_len) {
syn_unadd_group();
} else {
if (!error && is_normal_group) {
// Need to update all groups, because they might be using "bg" and/or
// "fg", which have been changed now.
@@ -1275,7 +1271,6 @@ void do_highlight(const char *line, const bool forceit, const bool init)
HL_TABLE()[idx].sg_script_ctx = current_sctx;
HL_TABLE()[idx].sg_script_ctx.sc_lnum += sourcing_lnum;
nlua_set_sctx(&HL_TABLE()[idx].sg_script_ctx);
}
// Only call highlight_changed() once, after a sequence of highlight
// commands, and only if an attribute actually changed
@@ -1739,7 +1734,7 @@ int syn_check_group(const char *name, size_t len)
///
/// @param name must be an allocated string, it will be consumed.
/// @return 0 for failure, else the allocated group id
/// @see syn_check_group syn_unadd_group
/// @see syn_check_group
static int syn_add_group(char_u *name)
{
char_u *p;
@@ -1792,17 +1787,6 @@ static int syn_add_group(char_u *name)
return id;
}
/// When, just after calling syn_add_group(), an error is discovered, this
/// function deletes the new name.
static void syn_unadd_group(void)
{
highlight_ga.ga_len--;
HlGroup *item = &HL_TABLE()[highlight_ga.ga_len];
map_del(cstr_t, int)(&highlight_unames, item->sg_name_u);
xfree(item->sg_name);
xfree(item->sg_name_u);
}
/// Translate a group ID to highlight attributes.
/// @see syn_attr2entry
int syn_id2attr(int hl_id)