]> granicus.if.org Git - vim/commitdiff
patch 7.4.1547 v7.4.1547
authorBram Moolenaar <Bram@vim.org>
Sat, 12 Mar 2016 18:23:00 +0000 (19:23 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 12 Mar 2016 18:23:00 +0000 (19:23 +0100)
Problem:    Getting a cterm highlight attribute that is not set results in the
            string "-1".
Solution:   Return an empty string. (Taro Muraoka)

src/syntax.c
src/testdir/test_alot.vim
src/testdir/test_syn_attr.vim [new file with mode: 0644]
src/version.c

index e37dacb8ffa7a89866a110b7a92a2c5f9a822129..ac80ab4e73c836f9cc72b0b4c0169d4eed1199e6 100644 (file)
@@ -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;
     }
index 60717569020801761ea687834dde298025dedb26..a1d819d824ade3d08db031cc18040ab233f13977 100644 (file)
@@ -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 (file)
index 0000000..20e9b17
--- /dev/null
@@ -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
index fc9cebea1b0bb7892da9fd6dc4a724d50cc6ecd7..c2ba5535f4c5c36c297aa62c32e278cb2771c011 100644 (file)
@@ -743,6 +743,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1547,
 /**/
     1546,
 /**/