vim-patch:8.0.1146: redraw when highlight is set with same names

Problem:    Redraw when highlight is set with same names. (Ozaki Kiichi)
Solution:   Only free and save a name when it changed. (closes vim/vim#2120)
452030e530
This commit is contained in:
Jan Edmund Lazo 2019-07-06 09:05:59 -04:00
parent 5dc5db1557
commit 6012e4a52c
1 changed files with 33 additions and 21 deletions

View File

@ -6823,18 +6823,22 @@ void do_highlight(const char *line, const bool forceit, const bool init)
}
}
} else if (strcmp(key, "GUIFG") == 0) {
char_u **const namep = &HL_TABLE()[idx].sg_rgb_fg_name;
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) {
if (!init) {
HL_TABLE()[idx].sg_set |= SG_GUI;
}
xfree(HL_TABLE()[idx].sg_rgb_fg_name);
if (strcmp(arg, "NONE") != 0) {
HL_TABLE()[idx].sg_rgb_fg_name = (char_u *)xstrdup((char *)arg);
HL_TABLE()[idx].sg_rgb_fg = name_to_color((const char_u *)arg);
} else {
HL_TABLE()[idx].sg_rgb_fg_name = NULL;
HL_TABLE()[idx].sg_rgb_fg = -1;
if (*namep == NULL || STRCMP(*namep, arg) != 0) {
xfree(*namep);
if (strcmp(arg, "NONE") != 0) {
*namep = (char_u *)xstrdup(arg);
HL_TABLE()[idx].sg_rgb_fg = name_to_color((char_u *)arg);
} else {
*namep = NULL;
HL_TABLE()[idx].sg_rgb_fg = -1;
}
}
}
@ -6842,18 +6846,22 @@ void do_highlight(const char *line, const bool forceit, const bool init)
normal_fg = HL_TABLE()[idx].sg_rgb_fg;
}
} else if (STRCMP(key, "GUIBG") == 0) {
char_u **const namep = &HL_TABLE()[idx].sg_rgb_bg_name;
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) {
if (!init) {
HL_TABLE()[idx].sg_set |= SG_GUI;
}
xfree(HL_TABLE()[idx].sg_rgb_bg_name);
if (STRCMP(arg, "NONE") != 0) {
HL_TABLE()[idx].sg_rgb_bg_name = (char_u *)xstrdup((char *)arg);
HL_TABLE()[idx].sg_rgb_bg = name_to_color((const char_u *)arg);
} else {
HL_TABLE()[idx].sg_rgb_bg_name = NULL;
HL_TABLE()[idx].sg_rgb_bg = -1;
if (*namep == NULL || STRCMP(*namep, arg) != 0) {
xfree(*namep);
if (STRCMP(arg, "NONE") != 0) {
*namep = (char_u *)xstrdup(arg);
HL_TABLE()[idx].sg_rgb_bg = name_to_color((char_u *)arg);
} else {
*namep = NULL;
HL_TABLE()[idx].sg_rgb_bg = -1;
}
}
}
@ -6861,18 +6869,22 @@ void do_highlight(const char *line, const bool forceit, const bool init)
normal_bg = HL_TABLE()[idx].sg_rgb_bg;
}
} else if (strcmp(key, "GUISP") == 0) {
char_u **const namep = &HL_TABLE()[idx].sg_rgb_sp_name;
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) {
if (!init) {
HL_TABLE()[idx].sg_set |= SG_GUI;
}
xfree(HL_TABLE()[idx].sg_rgb_sp_name);
if (strcmp(arg, "NONE") != 0) {
HL_TABLE()[idx].sg_rgb_sp_name = (char_u *)xstrdup((char *)arg);
HL_TABLE()[idx].sg_rgb_sp = name_to_color((const char_u *)arg);
} else {
HL_TABLE()[idx].sg_rgb_sp_name = NULL;
HL_TABLE()[idx].sg_rgb_sp = -1;
if (*namep == NULL || STRCMP(*namep, arg) != 0) {
xfree(*namep);
if (strcmp(arg, "NONE") != 0) {
*namep = (char_u *)xstrdup(arg);
HL_TABLE()[idx].sg_rgb_sp = name_to_color((char_u *)arg);
} else {
*namep = NULL;
HL_TABLE()[idx].sg_rgb_sp = -1;
}
}
}