mirror of
https://github.com/vim-airline/vim-airline.git
synced 2026-05-17 13:59:41 +08:00
whitespace: support multiline statusline for warnings
Add a new airline_section_warning2 that displays whitespace warnings on a second statusline line when Vim supports the statuslineopt option (Vim 9.2.0083+) and g:airline_multiline is set. The second line only appears when there are actual whitespace issues, avoiding an empty second line when the buffer is clean. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
@@ -161,6 +161,9 @@ function! airline#extensions#whitespace#check()
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if airline#util#has_multiline()
|
||||
return b:airline_whitespace_check
|
||||
endif
|
||||
return airline#util#shorten(b:airline_whitespace_check, 120, 9)
|
||||
endfunction
|
||||
|
||||
@@ -178,8 +181,16 @@ function! airline#extensions#whitespace#toggle()
|
||||
|
||||
if exists("g:airline#extensions#whitespace#enabled")
|
||||
let g:airline#extensions#whitespace#enabled = s:enabled
|
||||
if s:enabled && match(g:airline_section_warning, '#whitespace#check') < 0
|
||||
let g:airline_section_warning .= airline#section#create(['whitespace'])
|
||||
if s:enabled
|
||||
if airline#util#has_multiline() && exists('g:airline_section_warning2')
|
||||
if match(g:airline_section_warning2, '#whitespace#check') < 0
|
||||
let g:airline_section_warning2 .= airline#section#create(['whitespace'])
|
||||
endif
|
||||
else
|
||||
if match(g:airline_section_warning, '#whitespace#check') < 0
|
||||
let g:airline_section_warning .= airline#section#create(['whitespace'])
|
||||
endif
|
||||
endif
|
||||
call airline#update_statusline()
|
||||
endif
|
||||
endif
|
||||
@@ -211,7 +222,7 @@ function! s:ws_refresh()
|
||||
return
|
||||
endif
|
||||
unlet! b:airline_whitespace_check
|
||||
if get(g:, 'airline_skip_empty_sections', 0)
|
||||
if get(g:, 'airline_skip_empty_sections', 0) || airline#util#has_multiline()
|
||||
exe ':AirlineRefresh!'
|
||||
endif
|
||||
let b:airline_ws_changedtick = b:changedtick
|
||||
|
||||
Reference in New Issue
Block a user