Skip to content

Commit

Permalink
patch 8.0.1146: redraw when highlight is set with same names
Browse files Browse the repository at this point in the history
Problem:    Redraw when highlight is set with same names. (Ozaki Kiichi)
Solution:   Only free and save a name when it changed. (closes #2120)
  • Loading branch information
brammool committed Sep 25, 2017
1 parent 0c6a329 commit 452030e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 23 deletions.
77 changes: 54 additions & 23 deletions src/syntax.c
Expand Up @@ -7969,6 +7969,8 @@ do_highlight(
}
else if (STRCMP(key, "GUIFG") == 0)
{
char_u **namep = &HL_TABLE()[idx].sg_gui_fg_name;

#if defined(FEAT_GUI) || defined(FEAT_EVAL)
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI))
{
Expand All @@ -7982,22 +7984,33 @@ do_highlight(
{
HL_TABLE()[idx].sg_gui_fg = i;
# endif
vim_free(HL_TABLE()[idx].sg_gui_fg_name);
if (STRCMP(arg, "NONE") != 0)
HL_TABLE()[idx].sg_gui_fg_name = vim_strsave(arg);
else
HL_TABLE()[idx].sg_gui_fg_name = NULL;
if (*namep == NULL || STRCMP(*namep, arg) != 0)
{
vim_free(*namep);
if (STRCMP(arg, "NONE") != 0)
*namep = vim_strsave(arg);
else
*namep = NULL;
}
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
# ifdef FEAT_GUI_X11
if (is_menu_group)
if (is_menu_group && gui.menu_fg_pixel != i)
{
gui.menu_fg_pixel = i;
if (is_scrollbar_group)
do_colors = TRUE;
}
if (is_scrollbar_group && gui.scroll_fg_pixel != i)
{
gui.scroll_fg_pixel = i;
do_colors = TRUE;
}
# ifdef FEAT_BEVAL
if (is_tooltip_group)
if (is_tooltip_group && gui.tooltip_fg_pixel != i)
{
gui.tooltip_fg_pixel = i;
do_colors = TRUE;
}
# endif
do_colors = TRUE;
# endif
}
# endif
Expand All @@ -8006,6 +8019,8 @@ do_highlight(
}
else if (STRCMP(key, "GUIBG") == 0)
{
char_u **namep = &HL_TABLE()[idx].sg_gui_bg_name;

#if defined(FEAT_GUI) || defined(FEAT_EVAL)
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI))
{
Expand All @@ -8019,22 +8034,33 @@ do_highlight(
{
HL_TABLE()[idx].sg_gui_bg = i;
# endif
vim_free(HL_TABLE()[idx].sg_gui_bg_name);
if (STRCMP(arg, "NONE") != 0)
HL_TABLE()[idx].sg_gui_bg_name = vim_strsave(arg);
else
HL_TABLE()[idx].sg_gui_bg_name = NULL;
if (*namep == NULL || STRCMP(*namep, arg) != 0)
{
vim_free(*namep);
if (STRCMP(arg, "NONE") != 0)
*namep = vim_strsave(arg);
else
*namep = NULL;
}
# if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
# ifdef FEAT_GUI_X11
if (is_menu_group)
if (is_menu_group && gui.menu_bg_pixel != i)
{
gui.menu_bg_pixel = i;
if (is_scrollbar_group)
do_colors = TRUE;
}
if (is_scrollbar_group && gui.scroll_bg_pixel != i)
{
gui.scroll_bg_pixel = i;
do_colors = TRUE;
}
# ifdef FEAT_BEVAL
if (is_tooltip_group)
if (is_tooltip_group && gui.tooltip_bg_pixel != i)
{
gui.tooltip_bg_pixel = i;
do_colors = TRUE;
}
# endif
do_colors = TRUE;
# endif
}
# endif
Expand All @@ -8043,6 +8069,8 @@ do_highlight(
}
else if (STRCMP(key, "GUISP") == 0)
{
char_u **namep = &HL_TABLE()[idx].sg_gui_sp_name;

#if defined(FEAT_GUI) || defined(FEAT_EVAL)
if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI))
{
Expand All @@ -8055,11 +8083,14 @@ do_highlight(
{
HL_TABLE()[idx].sg_gui_sp = i;
# endif
vim_free(HL_TABLE()[idx].sg_gui_sp_name);
if (STRCMP(arg, "NONE") != 0)
HL_TABLE()[idx].sg_gui_sp_name = vim_strsave(arg);
else
HL_TABLE()[idx].sg_gui_sp_name = NULL;
if (*namep == NULL || STRCMP(*namep, arg) != 0)
{
vim_free(*namep);
if (STRCMP(arg, "NONE") != 0)
*namep = vim_strsave(arg);
else
*namep = NULL;
}
# ifdef FEAT_GUI
}
# endif
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -761,6 +761,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1146,
/**/
1145,
/**/
Expand Down

0 comments on commit 452030e

Please sign in to comment.