bug in statusline highlighting

86 views
Skip to first unread message

Christian Brabandt

unread,
Feb 2, 2016, 2:21:47 PM2/2/16
to vim...@vim.org
Hi,
here is a bug in the highlighting of the statusline, when using group
items:

:set laststatus=2
:let &stl='+foobar+'
(shows "+foobar+"
-> is okay)
:let &stl='+%(foobar%)+'
(shows "+foobar+"
-> is okay)
:let &stl='+%(%#ErrorMsg#foobar%)+'
(shows "++", everything after the second + with error highlighting
-> not okay)
:let &stl='+%(%#WildMenu#««««««%#Normal#%)-%#Statusline#
(shows "+-+ +", starting with the '-' until the third '+'
everything highlighted with WildMenu highlighting
-> not okay)

Screenshots available here:
https://i.imgur.com/n7Sa1gr.png

This is a problem for statusline highlighter plugins, since the colors
leak from one section to the next and make it hard to reproduce. I just
found this problem per accident today, when I wanted to fix another bug
in vim-airline.

This patch fixes it:
diff --git a/src/buffer.c b/src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3723,7 +3723,7 @@ build_stl_str_hl(
{
/* remove group if all items are empty */
for (n = groupitem[groupdepth] + 1; n < curitem; n++)
- if (item[n].type == Normal)
+ if (item[n].type == Normal || item[n].type == Highlight)
break;
if (n == curitem)
{


Best,
Christian
--
1,9 Prozent sind rechnerisch gesehen auch noch rund zwei Prozent.
-- Bernd Pfaffenbach
(Chefökonom des Bundeskanzleramtes, in der »Börsen-Zeitung« zu den
Aussichten für die Konjunktur in Deutschland)

Bram Moolenaar

unread,
Feb 2, 2016, 2:56:44 PM2/2/16
to Christian Brabandt, vim...@vim.org

Christian Brabandt wrote:

> here is a bug in the highlighting of the statusline, when using group
> items:
>
> :set laststatus=2
> :let &stl='+foobar+'
> (shows "+foobar+"
> -> is okay)
> :let &stl='+%(foobar%)+'
> (shows "+foobar+"
> -> is okay)
> :let &stl='+%(%#ErrorMsg#foobar%)+'
> (shows "++", everything after the second + with error highlighting
> -> not okay)
> :let &stl='+%(%#WildMenu#««««««%#Normal#%)-%#Statusline#
> (shows "+-+ +", starting with the '-' until the third '+'
> everything highlighted with WildMenu highlighting
> -> not okay)
>
> Screenshots available here:
> https://i.imgur.com/n7Sa1gr.png
>
> This is a problem for statusline highlighter plugins, since the colors
> leak from one section to the next and make it hard to reproduce. I just
> found this problem per accident today, when I wanted to fix another bug
> in vim-airline.

Thanks!


--
hundred-and-one symptoms of being an internet addict:
115. You are late picking up your kid from school and try to explain
to the teacher you were stuck in Web traffic.

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///
Reply all
Reply to author
Forward
0 new messages