fix(highlight): correct change detection in do_highlight for gui colors

Problem: The GUIFG/GUIBG/GUISP handlers compare sg_rgb_{fg,bg,sp}
(RgbValue) against old_idx (color table index) instead of comparing
sg_rgb_{fg,bg,sp}_idx against old_idx, making did_change unreliable.

Solution: Use the _idx field for the index comparison and add the
missing sg_rgb_sp_idx assignment.
This commit is contained in:
glepnir
2026-02-11 12:18:07 +08:00
parent e1b3ca6629
commit d5a8c9d766

View File

@@ -1418,7 +1418,8 @@ void do_highlight(const char *line, const bool forceit, const bool init)
hl_table[idx].sg_rgb_fg_idx = kColorIdxNone;
}
did_change = hl_table[idx].sg_rgb_fg != old_color || hl_table[idx].sg_rgb_fg != old_idx;
did_change = hl_table[idx].sg_rgb_fg != old_color
|| hl_table[idx].sg_rgb_fg_idx != old_idx;
}
if (is_normal_group) {
@@ -1442,7 +1443,8 @@ void do_highlight(const char *line, const bool forceit, const bool init)
hl_table[idx].sg_rgb_bg_idx = kColorIdxNone;
}
did_change = hl_table[idx].sg_rgb_bg != old_color || hl_table[idx].sg_rgb_bg != old_idx;
did_change = hl_table[idx].sg_rgb_bg != old_color
|| hl_table[idx].sg_rgb_bg_idx != old_idx;
}
if (is_normal_group) {
@@ -1463,9 +1465,11 @@ void do_highlight(const char *line, const bool forceit, const bool init)
hl_table[idx].sg_rgb_sp = name_to_color(arg, indexp);
} else {
hl_table[idx].sg_rgb_sp = -1;
hl_table[idx].sg_rgb_sp_idx = kColorIdxNone;
}
did_change = hl_table[idx].sg_rgb_sp != old_color || hl_table[idx].sg_rgb_sp != old_idx;
did_change = hl_table[idx].sg_rgb_sp != old_color
|| hl_table[idx].sg_rgb_sp_idx != old_idx;
}
if (is_normal_group) {