mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.0.0616: not always setting 'background' correctly after :hi Normal
Problem: When setting the cterm background with ":hi Normal" the value of 'background' may be set wrongly. Solution: Check that the color is less than 16. Don't set 'background' when it was set explicitly. (Lemonboy, closes #1710)
This commit is contained in:
19
src/syntax.c
19
src/syntax.c
@@ -7834,18 +7834,25 @@ do_highlight(
|
|||||||
must_redraw = CLEAR;
|
must_redraw = CLEAR;
|
||||||
if (color >= 0)
|
if (color >= 0)
|
||||||
{
|
{
|
||||||
|
int dark = -1;
|
||||||
|
|
||||||
if (termcap_active)
|
if (termcap_active)
|
||||||
term_bg_color(color);
|
term_bg_color(color);
|
||||||
if (t_colors < 16)
|
if (t_colors < 16)
|
||||||
i = (color == 0 || color == 4);
|
dark = (color == 0 || color == 4);
|
||||||
else
|
/* Limit the heuristic to the standard 16 colors */
|
||||||
i = (color < 7 || color == 8);
|
else if (color < 16)
|
||||||
|
dark = (color < 7 || color == 8);
|
||||||
/* Set the 'background' option if the value is
|
/* Set the 'background' option if the value is
|
||||||
* wrong. */
|
* wrong. */
|
||||||
if (i != (*p_bg == 'd'))
|
if (dark != -1
|
||||||
|
&& dark != (*p_bg == 'd')
|
||||||
|
&& !option_was_set((char_u *)"bg"))
|
||||||
|
{
|
||||||
set_option_value((char_u *)"bg", 0L,
|
set_option_value((char_u *)"bg", 0L,
|
||||||
i ? (char_u *)"dark"
|
(char_u *)(dark ? "dark" : "light"), 0);
|
||||||
: (char_u *)"light", 0);
|
reset_option_was_set((char_u *)"bg");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -401,3 +401,26 @@ func Test_highlight_invalid_arg()
|
|||||||
call assert_fails('hi XXX xxx=White', 'E423:')
|
call assert_fails('hi XXX xxx=White', 'E423:')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_bg_detection()
|
||||||
|
if has('gui_running')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
" auto-detection of &bg, make sure sure it isn't set anywhere before
|
||||||
|
" this test
|
||||||
|
hi Normal ctermbg=0
|
||||||
|
call assert_equal('dark', &bg)
|
||||||
|
hi Normal ctermbg=4
|
||||||
|
call assert_equal('dark', &bg)
|
||||||
|
hi Normal ctermbg=12
|
||||||
|
call assert_equal('light', &bg)
|
||||||
|
hi Normal ctermbg=15
|
||||||
|
call assert_equal('light', &bg)
|
||||||
|
|
||||||
|
" manually-set &bg takes precendence over auto-detection
|
||||||
|
set bg=light
|
||||||
|
hi Normal ctermbg=4
|
||||||
|
call assert_equal('light', &bg)
|
||||||
|
set bg=dark
|
||||||
|
hi Normal ctermbg=12
|
||||||
|
call assert_equal('dark', &bg)
|
||||||
|
endfunc
|
||||||
|
@@ -764,6 +764,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
616,
|
||||||
/**/
|
/**/
|
||||||
615,
|
615,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user