Skip to content

Commit 385111b

Browse files
committed
patch 7.4.1547
Problem: Getting a cterm highlight attribute that is not set results in the string "-1". Solution: Return an empty string. (Taro Muraoka)
1 parent f6f32c3 commit 385111b

4 files changed

Lines changed: 36 additions & 0 deletions

File tree

src/syntax.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8999,6 +8999,8 @@ highlight_color(
89998999
n = HL_TABLE()[id - 1].sg_cterm_fg - 1;
90009000
else
90019001
n = HL_TABLE()[id - 1].sg_cterm_bg - 1;
9002+
if (n < 0)
9003+
return NULL;
90029004
sprintf((char *)name, "%d", n);
90039005
return name;
90049006
}

src/testdir/test_alot.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ source test_reltime.vim
1616
source test_searchpos.vim
1717
source test_set.vim
1818
source test_sort.vim
19+
source test_syn_attr.vim
1920
source test_undolevels.vim
2021
source test_unlet.vim

src/testdir/test_syn_attr.vim

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
" Test syntax highlighting functions.
2+
3+
func Test_missing_attr()
4+
hi Mine term=bold cterm=italic
5+
call assert_equal('Mine', synIDattr(hlID("Mine"), "name"))
6+
call assert_equal('', synIDattr(hlID("Mine"), "bg", 'term'))
7+
call assert_equal('1', synIDattr(hlID("Mine"), "bold", 'term'))
8+
call assert_equal('1', synIDattr(hlID("Mine"), "italic", 'cterm'))
9+
hi Mine term=reverse cterm=inverse
10+
call assert_equal('1', synIDattr(hlID("Mine"), "reverse", 'term'))
11+
call assert_equal('1', synIDattr(hlID("Mine"), "inverse", 'cterm'))
12+
hi Mine term=underline cterm=standout gui=undercurl
13+
call assert_equal('1', synIDattr(hlID("Mine"), "underline", 'term'))
14+
call assert_equal('1', synIDattr(hlID("Mine"), "standout", 'cterm'))
15+
call assert_equal('1', synIDattr(hlID("Mine"), "undercurl", 'gui'))
16+
hi Mine term=NONE cterm=NONE gui=NONE
17+
call assert_equal('', synIDattr(hlID("Mine"), "bold", 'term'))
18+
call assert_equal('', synIDattr(hlID("Mine"), "italic", 'cterm'))
19+
call assert_equal('', synIDattr(hlID("Mine"), "reverse", 'term'))
20+
call assert_equal('', synIDattr(hlID("Mine"), "inverse", 'cterm'))
21+
call assert_equal('', synIDattr(hlID("Mine"), "underline", 'term'))
22+
call assert_equal('', synIDattr(hlID("Mine"), "standout", 'cterm'))
23+
call assert_equal('', synIDattr(hlID("Mine"), "undercurl", 'gui'))
24+
25+
if has('gui')
26+
hi Mine guifg=blue guibg=red font=something
27+
call assert_equal('blue', synIDattr(hlID("Mine"), "fg", 'gui'))
28+
call assert_equal('red', synIDattr(hlID("Mine"), "bg", 'gui'))
29+
call assert_equal('something', synIDattr(hlID("Mine"), "font", 'gui'))
30+
endif
31+
endfunc

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,8 @@ static char *(features[]) =
743743

744744
static int included_patches[] =
745745
{ /* Add new patch number below this line */
746+
/**/
747+
1547,
746748
/**/
747749
1546,
748750
/**/

0 commit comments

Comments
 (0)