mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-02-07 17:25:34 +08:00
highlighter: remove stale separator entries on buffer unload
Some checks failed
CI / Test (v7.4) (push) Has been cancelled
CI / Test (v8.0.0000) (push) Has been cancelled
CI / Test (v8.1.0000) (push) Has been cancelled
CI / Test (v8.2.0000) (push) Has been cancelled
CI / Test (v8.2.1000) (push) Has been cancelled
CI / Test (v9.0.0000) (push) Has been cancelled
CI / Test (v9.1.0000) (push) Has been cancelled
reviewdog / runner / vint (push) Has been cancelled
Some checks failed
CI / Test (v7.4) (push) Has been cancelled
CI / Test (v8.0.0000) (push) Has been cancelled
CI / Test (v8.1.0000) (push) Has been cancelled
CI / Test (v8.2.0000) (push) Has been cancelled
CI / Test (v8.2.1000) (push) Has been cancelled
CI / Test (v9.0.0000) (push) Has been cancelled
CI / Test (v9.1.0000) (push) Has been cancelled
reviewdog / runner / vint (push) Has been cancelled
fixes: #2701 Co-authored-by: Mina Nagy Zaki <mnzaki@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
25635ab504
commit
7a552f415c
|
@ -186,6 +186,13 @@ if !exists(":def") || !airline#util#has_vim9_script()
|
||||||
call <sid>exec_separator({}, a:from, a:to, a:inverse, '')
|
call <sid>exec_separator({}, a:from, a:to, a:inverse, '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! airline#highlighter#remove_separators_for_bufnr(bufnr) abort
|
||||||
|
" remove all separators, that have the buffer number in their name,
|
||||||
|
" but do not be too greedy!
|
||||||
|
let pat = 'c' . a:bufnr . '\(\D\|$\)'
|
||||||
|
call filter(s:separators, 'v:key !~# pat')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:exec_separator(dict, from, to, inverse, suffix) abort
|
function! s:exec_separator(dict, from, to, inverse, suffix) abort
|
||||||
if pumvisible()
|
if pumvisible()
|
||||||
return
|
return
|
||||||
|
@ -529,6 +536,13 @@ else
|
||||||
s:exec_separator({}, from, to, inverse, '')
|
s:exec_separator({}, from, to, inverse, '')
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def airline#highlighter#remove_separators_for_bufnr(bufnr: string): void
|
||||||
|
# remove all separators, that have the bufnr in its name, make sure we
|
||||||
|
# have a full match here
|
||||||
|
const pat = $'c{bufnr}\(\D\|$\)'
|
||||||
|
filter(s:separators, (k, v) => k !~# pat)
|
||||||
|
enddef
|
||||||
|
|
||||||
def s:exec_separator(dict: dict<any>, from_arg: string, to_arg: string, inverse: bool, suffix: string): void
|
def s:exec_separator(dict: dict<any>, from_arg: string, to_arg: string, inverse: bool, suffix: string): void
|
||||||
if pumvisible()
|
if pumvisible()
|
||||||
return
|
return
|
||||||
|
@ -681,5 +695,5 @@ else
|
||||||
endfor
|
endfor
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
enddef
|
enddef
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -48,6 +48,7 @@ function! s:init()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let s:active_winnr = -1
|
let s:active_winnr = -1
|
||||||
|
|
||||||
function! s:on_window_changed(event)
|
function! s:on_window_changed(event)
|
||||||
" don't trigger for Vim popup windows
|
" don't trigger for Vim popup windows
|
||||||
if &buftype is# 'popup'
|
if &buftype is# 'popup'
|
||||||
|
@ -67,11 +68,20 @@ function! s:on_window_changed(event)
|
||||||
\ && &ft !~? 'gitcommit'
|
\ && &ft !~? 'gitcommit'
|
||||||
" fugitive is special, it changes names and filetypes several times,
|
" fugitive is special, it changes names and filetypes several times,
|
||||||
" make sure the caching does not get into its way
|
" make sure the caching does not get into its way
|
||||||
|
if a:event ==# 'BufUnload'
|
||||||
|
" in the BufUnload event, make sure the cacheing does not prevent
|
||||||
|
" removing stale entries
|
||||||
|
call airline#highlighter#remove_separators_for_bufnr(expand('<abuf>'))
|
||||||
|
endif
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let g:airline_last_window_changed = l:key
|
let g:airline_last_window_changed = l:key
|
||||||
call s:init()
|
call s:init()
|
||||||
call airline#update_statusline()
|
call airline#update_statusline()
|
||||||
|
|
||||||
|
if a:event ==# 'BufUnload'
|
||||||
|
call airline#highlighter#remove_separators_for_bufnr(expand('<abuf>'))
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:on_focus_gained()
|
function! s:on_focus_gained()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user