]> granicus.if.org Git - vim/commitdiff
patch 8.0.1220: skipping empty statusline groups is not correct v8.0.1220
authorBram Moolenaar <Bram@vim.org>
Thu, 26 Oct 2017 16:21:24 +0000 (18:21 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 26 Oct 2017 16:21:24 +0000 (18:21 +0200)
Problem:    Skipping empty statusline groups is not correct.
Solution:   Also set group_end_userhl. (itchyny)

src/buffer.c
src/testdir/test_statusline.vim
src/version.c

index 0d69b9d66b813cce295261aab46865df6f4d00f5..dad910388b73ec36b6cf811ab42acea4994b6bb2 100644 (file)
@@ -4028,9 +4028,14 @@ build_stl_str_hl(
                /* remove group if all items are empty and highlight group
                 * doesn't change */
                group_start_userhl = group_end_userhl = 0;
-               for (n = 0; n < groupitem[groupdepth]; n++)
+               for (n = groupitem[groupdepth] - 1; n >= 0; n--)
+               {
                    if (item[n].type == Highlight)
-                       group_start_userhl = item[n].minwid;
+                   {
+                       group_start_userhl = group_end_userhl = item[n].minwid;
+                       break;
+                   }
+               }
                for (n = groupitem[groupdepth] + 1; n < curitem; n++)
                {
                    if (item[n].type == Normal)
index de943f24666f1fa6be8cef33d54401ecea0a0fa6..eafbecdf69fe6b26652f9c0630c9c9e89fab893a 100644 (file)
@@ -312,6 +312,12 @@ func Test_statusline()
   call assert_equal(sa1, sa3)
   call assert_equal(sa1, sa4)
 
+  let g:a = ''
+  set statusline=%#Error#{%(\ %{g:a}\ %)}
+  call assert_match('^{}\s*$', s:get_statusline())
+  let g:a = 'X'
+  call assert_match('^{ X }\s*$', s:get_statusline())
+
   " %%: a percent sign.
   set statusline=10%%
   call assert_match('^10%\s*$', s:get_statusline())
index 7f72146ea7adff82c1a5dd489634883c71ec56d7..a3b48b52ff33e29a235a42fae367a22df2f6f903 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1220,
 /**/
     1219,
 /**/