mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-01-31 09:16:17 +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, '')
|
||||
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
|
||||
if pumvisible()
|
||||
return
|
||||
|
@ -529,6 +536,13 @@ else
|
|||
s:exec_separator({}, from, to, inverse, '')
|
||||
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
|
||||
if pumvisible()
|
||||
return
|
||||
|
@ -681,5 +695,5 @@ else
|
|||
endfor
|
||||
endif
|
||||
endfor
|
||||
enddef
|
||||
enddef
|
||||
endif
|
||||
|
|
|
@ -48,6 +48,7 @@ function! s:init()
|
|||
endfunction
|
||||
|
||||
let s:active_winnr = -1
|
||||
|
||||
function! s:on_window_changed(event)
|
||||
" don't trigger for Vim popup windows
|
||||
if &buftype is# 'popup'
|
||||
|
@ -67,11 +68,20 @@ function! s:on_window_changed(event)
|
|||
\ && &ft !~? 'gitcommit'
|
||||
" fugitive is special, it changes names and filetypes several times,
|
||||
" 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
|
||||
endif
|
||||
let g:airline_last_window_changed = l:key
|
||||
call s:init()
|
||||
call airline#update_statusline()
|
||||
|
||||
if a:event ==# 'BufUnload'
|
||||
call airline#highlighter#remove_separators_for_bufnr(expand('<abuf>'))
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:on_focus_gained()
|
||||
|
|
Loading…
Reference in New Issue
Block a user