summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-03-12 19:23:00 +0100
committerBram Moolenaar <Bram@vim.org>2016-03-12 19:23:00 +0100
commit385111bd86e0b38667879c3e89506ca1ae98e1df (patch)
tree5f1c3d68cd38bed97cec68adb2e61e4415d81f2b
parentf6f32c38bf3319144a84a01a154c8c91939e7acf (diff)
patch 7.4.1547v7.4.1547
Problem: Getting a cterm highlight attribute that is not set results in the string "-1". Solution: Return an empty string. (Taro Muraoka)
-rw-r--r--src/syntax.c2
-rw-r--r--src/testdir/test_alot.vim1
-rw-r--r--src/testdir/test_syn_attr.vim31
-rw-r--r--src/version.c2
4 files changed, 36 insertions, 0 deletions
diff --git a/src/syntax.c b/src/syntax.c
index e37dacb8ff..ac80ab4e73 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -8999,6 +8999,8 @@ highlight_color(
n = HL_TABLE()[id - 1].sg_cterm_fg - 1;
else
n = HL_TABLE()[id - 1].sg_cterm_bg - 1;
+ if (n < 0)
+ return NULL;
sprintf((char *)name, "%d", n);
return name;
}
diff --git a/src/testdir/test_alot.vim b/src/testdir/test_alot.vim
index 6071756902..a1d819d824 100644
--- a/src/testdir/test_alot.vim
+++ b/src/testdir/test_alot.vim
@@ -16,5 +16,6 @@ source test_reltime.vim
source test_searchpos.vim
source test_set.vim
source test_sort.vim
+source test_syn_attr.vim
source test_undolevels.vim
source test_unlet.vim
diff --git a/src/testdir/test_syn_attr.vim b/src/testdir/test_syn_attr.vim
new file mode 100644
index 0000000000..20e9b17c46
--- /dev/null
+++ b/src/testdir/test_syn_attr.vim
@@ -0,0 +1,31 @@
+" Test syntax highlighting functions.
+
+func Test_missing_attr()
+ hi Mine term=bold cterm=italic
+ call assert_equal('Mine', synIDattr(hlID("Mine"), "name"))
+ call assert_equal('', synIDattr(hlID("Mine"), "bg", 'term'))
+ call assert_equal('1', synIDattr(hlID("Mine"), "bold", 'term'))
+ call assert_equal('1', synIDattr(hlID("Mine"), "italic", 'cterm'))
+ hi Mine term=reverse cterm=inverse
+ call assert_equal('1', synIDattr(hlID("Mine"), "reverse", 'term'))
+ call assert_equal('1', synIDattr(hlID("Mine"), "inverse", 'cterm'))
+ hi Mine term=underline cterm=standout gui=undercurl
+ call assert_equal('1', synIDattr(hlID("Mine"), "underline", 'term'))
+ call assert_equal('1', synIDattr(hlID("Mine"), "standout", 'cterm'))
+ call assert_equal('1', synIDattr(hlID("Mine"), "undercurl", 'gui'))
+ hi Mine term=NONE cterm=NONE gui=NONE
+ call assert_equal('', synIDattr(hlID("Mine"), "bold", 'term'))
+ call assert_equal('', synIDattr(hlID("Mine"), "italic", 'cterm'))
+ call assert_equal('', synIDattr(hlID("Mine"), "reverse", 'term'))
+ call assert_equal('', synIDattr(hlID("Mine"), "inverse", 'cterm'))
+ call assert_equal('', synIDattr(hlID("Mine"), "underline", 'term'))
+ call assert_equal('', synIDattr(hlID("Mine"), "standout", 'cterm'))
+ call assert_equal('', synIDattr(hlID("Mine"), "undercurl", 'gui'))
+
+ if has('gui')
+ hi Mine guifg=blue guibg=red font=something
+ call assert_equal('blue', synIDattr(hlID("Mine"), "fg", 'gui'))
+ call assert_equal('red', synIDattr(hlID("Mine"), "bg", 'gui'))
+ call assert_equal('something', synIDattr(hlID("Mine"), "font", 'gui'))
+ endif
+endfunc
diff --git a/src/version.c b/src/version.c
index fc9cebea1b..c2ba5535f4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -744,6 +744,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1547,
+/**/
1546,
/**/
1545,