builder: correctly remember the previous group when switching alignment

When `g:airline_skip_empty_sections' is set, and a section is considered
and after that section comes the alignment separator '%=' than airline
would not correctly render the airline_prevgroup_to_airline_curgroup
simply because the '%=' marker confuses it about which is actually the
previous group.

So consider the '%=' marker to be empty as well.

The case can be observed, when having set
`g:airline_skip_empty_sections' to true and opening a help buffer.
Because in that case, airline_section_c will be considered empty, then
the alignment separator comes and after that airline will (wrongly)
generate a highlighting group `airline_c_to_airline_z`, while it should
actually generate `airline_b_to_airline_z`
This commit is contained in:
Christian Brabandt 2022-09-02 11:03:05 +02:00
parent f5a6597496
commit 90c6746311
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09
1 changed files with 6 additions and 1 deletions

View File

@ -199,7 +199,12 @@ function! s:section_is_empty(self, content)
return 0
endif
if empty(a:content)
" special case: When the content is %=, that is the
" separation marker, which switches between left- and
" right-aligned content.
" Consider that to be empty, so that the previous previous
" group is correctly remembered in the builder() function
if empty(a:content) || a:content is# '%='
return 1
endif