mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-12-16 00:37:08 +08:00
Honor minwidth for hunks and branch parts
This removes the hardcoded minwidth limits for both the `hunks` and `branch` parts. It replaces these with safe accesses to the `minwidth` setting as done by `airline#parts#define_minwidth`.
This commit is contained in:
@@ -266,8 +266,9 @@ function! airline#extensions#branch#head()
|
||||
endif
|
||||
endif
|
||||
|
||||
let winwidth = get(airline#parts#get('branch'), 'minwidth', 120)
|
||||
let minwidth = empty(get(b:, 'airline_hunks', '')) ? 14 : 7
|
||||
let b:airline_head = airline#util#shorten(b:airline_head, 120, minwidth)
|
||||
let b:airline_head = airline#util#shorten(b:airline_head, winwidth, minwidth)
|
||||
return b:airline_head
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -75,9 +75,10 @@ function! airline#extensions#hunks#get_hunks()
|
||||
endif
|
||||
let hunks = s:get_hunks()
|
||||
let string = ''
|
||||
let winwidth = get(airline#parts#get('hunks'), 'minwidth', 100)
|
||||
if !empty(hunks)
|
||||
for i in [0, 1, 2]
|
||||
if (s:non_zero_only == 0 && airline#util#winwidth() > 100) || hunks[i] > 0
|
||||
if (s:non_zero_only == 0 && airline#util#winwidth() > winwidth) || hunks[i] > 0
|
||||
let string .= printf('%s%s ', s:hunk_symbols[i], hunks[i])
|
||||
endif
|
||||
endfor
|
||||
|
||||
Reference in New Issue
Block a user