diff options
author | Bram Moolenaar <Bram@vim.org> | 2017-06-04 21:06:09 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2017-06-04 21:06:09 +0200 |
commit | 1615b36b91b094263240d7b555283ddf33208f62 (patch) | |
tree | d1b6b239f7e782080587529319455361c23fd11c /src/syntax.c | |
parent | bf15b8d78b22661db8b19d662b62bb9a061cdd37 (diff) | |
download | vim-git-1615b36b91b094263240d7b555283ddf33208f62.tar.gz |
patch 8.0.0616: not always setting 'background' correctly after :hi Normalv8.0.0616
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)
Diffstat (limited to 'src/syntax.c')
-rw-r--r-- | src/syntax.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/syntax.c b/src/syntax.c index 42a0bdc3f..10805f4e8 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -7834,18 +7834,25 @@ do_highlight( must_redraw = CLEAR; if (color >= 0) { + int dark = -1; + if (termcap_active) term_bg_color(color); if (t_colors < 16) - i = (color == 0 || color == 4); - else - i = (color < 7 || color == 8); + dark = (color == 0 || color == 4); + /* Limit the heuristic to the standard 16 colors */ + else if (color < 16) + dark = (color < 7 || color == 8); /* Set the 'background' option if the value is * 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, - i ? (char_u *)"dark" - : (char_u *)"light", 0); + (char_u *)(dark ? "dark" : "light"), 0); + reset_option_was_set((char_u *)"bg"); + } } } } |