Patch 8.0.1208
Problem:    'statusline' drops empty group with highlight change.
Solution:   Do not drop an empty group if it changes highlighting. (Marius
            Gedminas, closes #2228)
Files:      src/buffer.c, src/testdir/test_statusline.vim


*** ../vim-8.0.1207/src/buffer.c        2017-10-14 21:15:49.307655074 +0200
--- src/buffer.c        2017-10-21 19:44:44.764984806 +0200
***************
*** 3883,3888 ****
--- 3883,3890 ----
      int               width;
      int               itemcnt;
      int               curitem;
+     int               group_end_userhl;
+     int               group_start_userhl;
      int               groupitem[STL_MAX_ITEM];
      int               groupdepth;
      struct stl_item
***************
*** 4023,4033 ****
            if (curitem > groupitem[groupdepth] + 1
                    && item[groupitem[groupdepth]].minwid == 0)
            {
!               /* remove group if all items are empty */
                for (n = groupitem[groupdepth] + 1; n < curitem; n++)
!                   if (item[n].type == Normal || item[n].type == Highlight)
                        break;
!               if (n == curitem)
                {
                    p = t;
                    l = 0;
--- 4025,4044 ----
            if (curitem > groupitem[groupdepth] + 1
                    && item[groupitem[groupdepth]].minwid == 0)
            {
!               /* 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++)
!                   if (item[n].type == Highlight)
!                       group_start_userhl = item[n].minwid;
                for (n = groupitem[groupdepth] + 1; n < curitem; n++)
!               {
!                   if (item[n].type == Normal)
                        break;
!                   if (item[n].type == Highlight)
!                       group_end_userhl = item[n].minwid;
!               }
!               if (n == curitem && group_start_userhl == group_end_userhl)
                {
                    p = t;
                    l = 0;
*** ../vim-8.0.1207/src/testdir/test_statusline.vim     2017-06-17 
20:08:16.312896717 +0200
--- src/testdir/test_statusline.vim     2017-10-21 19:44:44.764984806 +0200
***************
*** 5,11 ****
  "   %N
  "   %T
  "   %X
- "   %*
  
  source view_util.vim
  
--- 5,10 ----
***************
*** 249,254 ****
--- 248,317 ----
    call assert_equal(sa1, sa3)
    call assert_notequal(sa1, sa2)
  
+   " An empty group that contains highlight changes
+   let g:a = ''
+   set statusline=ab%(cd%1*%{g:a}%*%)de
+   call assert_match('^abde\s*$', s:get_statusline())
+   let sa1=screenattr(&lines - 1, 1)
+   let sa2=screenattr(&lines - 1, 4)
+   call assert_equal(sa1, sa2)
+   let g:a = 'X'
+   call assert_match('^abcdXde\s*$', s:get_statusline())
+   let sa1=screenattr(&lines - 1, 1)
+   let sa2=screenattr(&lines - 1, 5)
+   let sa3=screenattr(&lines - 1, 7)
+   call assert_equal(sa1, sa3)
+   call assert_notequal(sa1, sa2)
+ 
+   let g:a = ''
+   set statusline=ab%1*%(cd%*%{g:a}%1*%)de
+   call assert_match('^abde\s*$', s:get_statusline())
+   let sa1=screenattr(&lines - 1, 1)
+   let sa2=screenattr(&lines - 1, 4)
+   call assert_notequal(sa1, sa2)
+   let g:a = 'X'
+   call assert_match('^abcdXde\s*$', s:get_statusline())
+   let sa1=screenattr(&lines - 1, 1)
+   let sa2=screenattr(&lines - 1, 3)
+   let sa3=screenattr(&lines - 1, 5)
+   let sa4=screenattr(&lines - 1, 7)
+   call assert_notequal(sa1, sa2)
+   call assert_equal(sa1, sa3)
+   call assert_equal(sa2, sa4)
+ 
+   " An empty group that contains highlight changes and doesn't reset them
+   let g:a = ''
+   set statusline=ab%(cd%1*%{g:a}%)de
+   call assert_match('^abcdde\s*$', s:get_statusline())
+   let sa1=screenattr(&lines - 1, 1)
+   let sa2=screenattr(&lines - 1, 5)
+   call assert_notequal(sa1, sa2)
+   let g:a = 'X'
+   call assert_match('^abcdXde\s*$', s:get_statusline())
+   let sa1=screenattr(&lines - 1, 1)
+   let sa2=screenattr(&lines - 1, 5)
+   let sa3=screenattr(&lines - 1, 7)
+   call assert_notequal(sa1, sa2)
+   call assert_equal(sa2, sa3)
+ 
+   let g:a = ''
+   set statusline=ab%1*%(cd%*%{g:a}%)de
+   call assert_match('^abcdde\s*$', s:get_statusline())
+   let sa1=screenattr(&lines - 1, 1)
+   let sa2=screenattr(&lines - 1, 3)
+   let sa3=screenattr(&lines - 1, 5)
+   call assert_notequal(sa1, sa2)
+   call assert_equal(sa1, sa3)
+   let g:a = 'X'
+   call assert_match('^abcdXde\s*$', s:get_statusline())
+   let sa1=screenattr(&lines - 1, 1)
+   let sa2=screenattr(&lines - 1, 3)
+   let sa3=screenattr(&lines - 1, 5)
+   let sa4=screenattr(&lines - 1, 7)
+   call assert_notequal(sa1, sa2)
+   call assert_equal(sa1, sa3)
+   call assert_equal(sa1, sa4)
+ 
    " %%: a percent sign.
    set statusline=10%%
    call assert_match('^10%\s*$', s:get_statusline())
*** ../vim-8.0.1207/src/version.c       2017-10-19 21:04:33.473886033 +0200
--- src/version.c       2017-10-22 14:21:20.897145690 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     1208,
  /**/

-- 
A poem:                read aloud:

<> !*''#               Waka waka bang splat tick tick hash,
^"`$$-                 Caret quote back-tick dollar dollar dash,
!*=@$_                 Bang splat equal at dollar under-score,
%*<> ~#4               Percent splat waka waka tilde number four,
&[]../                 Ampersand bracket bracket dot dot slash,
|{,,SYSTEM HALTED      Vertical-bar curly-bracket comma comma CRASH.

Fred Bremmer and Steve Kroese (Calvin College & Seminary of Grand Rapids, MI.)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui