mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
vim-patch:8.0.1208: 'statusline' drops empty group with highlight change
Problem: 'statusline' drops empty group with highlight change.
Solution: Do not drop an empty group if it changes highlighting. (Marius
Gedminas, closes vim/vim#2228)
6b89dbb55f
This commit is contained in:
@@ -3480,15 +3480,25 @@ int build_stl_str_hl(
|
|||||||
// Otherwise there would be no reason to do this step.
|
// Otherwise there would be no reason to do this step.
|
||||||
if (curitem > groupitems[groupdepth] + 1
|
if (curitem > groupitems[groupdepth] + 1
|
||||||
&& items[groupitems[groupdepth]].minwid == 0) {
|
&& items[groupitems[groupdepth]].minwid == 0) {
|
||||||
bool has_normal_items = false;
|
// remove group if all items are empty and highlight group
|
||||||
for (long n = groupitems[groupdepth] + 1; n < curitem; n++) {
|
// doesn't change
|
||||||
if (items[n].type == Normal || items[n].type == Highlight) {
|
int group_start_userhl = 0;
|
||||||
has_normal_items = true;
|
int group_end_userhl = 0;
|
||||||
break;
|
int n;
|
||||||
|
for (n = 0; n < groupitems[groupdepth]; n++) {
|
||||||
|
if (items[n].type == Highlight) {
|
||||||
|
group_start_userhl = items[n].minwid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (n = groupitems[groupdepth] + 1; n < curitem; n++) {
|
||||||
if (!has_normal_items) {
|
if (items[n].type == Normal) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (items[n].type == Highlight) {
|
||||||
|
group_end_userhl = items[n].minwid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (n == curitem && group_start_userhl == group_end_userhl) {
|
||||||
out_p = t;
|
out_p = t;
|
||||||
group_len = 0;
|
group_len = 0;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
" %N
|
" %N
|
||||||
" %T
|
" %T
|
||||||
" %X
|
" %X
|
||||||
" %*
|
|
||||||
|
|
||||||
source view_util.vim
|
source view_util.vim
|
||||||
|
|
||||||
@@ -249,6 +248,70 @@ func Test_statusline()
|
|||||||
call assert_equal(sa1, sa3)
|
call assert_equal(sa1, sa3)
|
||||||
call assert_notequal(sa1, sa2)
|
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.
|
" %%: a percent sign.
|
||||||
set statusline=10%%
|
set statusline=10%%
|
||||||
call assert_match('^10%\s*$', s:get_statusline())
|
call assert_match('^10%\s*$', s:get_statusline())
|
||||||
|
Reference in New Issue
Block a user