Skip to content

Commit 235dddf

Browse files
committed
patch 8.0.1220: skipping empty statusline groups is not correct
Problem: Skipping empty statusline groups is not correct. Solution: Also set group_end_userhl. (itchyny)
1 parent f204e05 commit 235dddf

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

src/buffer.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4028,9 +4028,14 @@ build_stl_str_hl(
40284028
/* remove group if all items are empty and highlight group
40294029
* doesn't change */
40304030
group_start_userhl = group_end_userhl = 0;
4031-
for (n = 0; n < groupitem[groupdepth]; n++)
4031+
for (n = groupitem[groupdepth] - 1; n >= 0; n--)
4032+
{
40324033
if (item[n].type == Highlight)
4033-
group_start_userhl = item[n].minwid;
4034+
{
4035+
group_start_userhl = group_end_userhl = item[n].minwid;
4036+
break;
4037+
}
4038+
}
40344039
for (n = groupitem[groupdepth] + 1; n < curitem; n++)
40354040
{
40364041
if (item[n].type == Normal)

src/testdir/test_statusline.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,12 @@ func Test_statusline()
312312
call assert_equal(sa1, sa3)
313313
call assert_equal(sa1, sa4)
314314

315+
let g:a = ''
316+
set statusline=%#Error#{%(\ %{g:a}\ %)}
317+
call assert_match('^{}\s*$', s:get_statusline())
318+
let g:a = 'X'
319+
call assert_match('^{ X }\s*$', s:get_statusline())
320+
315321
" %%: a percent sign.
316322
set statusline=10%%
317323
call assert_match('^10%\s*$', s:get_statusline())

src/version.c

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

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1220,
764766
/**/
765767
1219,
766768
/**/

0 commit comments

Comments
 (0)