mirror of
https://github.com/vim-airline/vim-airline.git
synced 2025-07-27 16:04:39 +02:00
branch: disable FocusGained handler when updating fugitive information
closes #2029
This commit is contained in:
parent
d4502d02a1
commit
f4795532c6
@ -112,6 +112,9 @@ function! s:update_git_branch()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:display_git_branch()
|
function! s:display_git_branch()
|
||||||
|
" disable FocusGained autocommand, might cause loops because system() causes
|
||||||
|
" a refresh, which causes a system() command again #2029
|
||||||
|
call airline#util#focusgain(0)
|
||||||
let name = b:buffer_vcs_config['git'].branch
|
let name = b:buffer_vcs_config['git'].branch
|
||||||
try
|
try
|
||||||
let commit = matchstr(FugitiveParse()[0], '^\x\+')
|
let commit = matchstr(FugitiveParse()[0], '^\x\+')
|
||||||
@ -128,7 +131,7 @@ function! s:display_git_branch()
|
|||||||
endif
|
endif
|
||||||
catch
|
catch
|
||||||
endtry
|
endtry
|
||||||
|
call airline#util#focusgain(1)
|
||||||
return name
|
return name
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ let s:spc = g:airline_symbols.space
|
|||||||
let s:nomodeline = (v:version > 703 || (v:version == 703 && has("patch438"))) ? '<nomodeline>' : ''
|
let s:nomodeline = (v:version > 703 || (v:version == 703 && has("patch438"))) ? '<nomodeline>' : ''
|
||||||
let s:has_strchars = exists('*strchars')
|
let s:has_strchars = exists('*strchars')
|
||||||
let s:has_strcharpart = exists('*strcharpart')
|
let s:has_strcharpart = exists('*strcharpart')
|
||||||
|
let s:focusgained_enabled = 0
|
||||||
|
|
||||||
" TODO: Try to cache winwidth(0) function
|
" TODO: Try to cache winwidth(0) function
|
||||||
" e.g. store winwidth per window and access that, only update it, if the size
|
" e.g. store winwidth per window and access that, only update it, if the size
|
||||||
@ -190,3 +191,11 @@ function! airline#util#stl_disabled(winnr)
|
|||||||
\ airline#util#getwinvar(a:winnr, 'airline_disabled', 0) ||
|
\ airline#util#getwinvar(a:winnr, 'airline_disabled', 0) ||
|
||||||
\ airline#util#getbufvar(winbufnr(a:winnr), 'airline_disable_statusline', 0)
|
\ airline#util#getbufvar(winbufnr(a:winnr), 'airline_disable_statusline', 0)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! airline#util#focusgain(allow)
|
||||||
|
let s:focusgained_enabled = a:allow
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! airline#util#focusgained_disabled()
|
||||||
|
return s:focusgained_enabled < 1
|
||||||
|
endfunction
|
||||||
|
@ -82,6 +82,13 @@ function! s:on_window_changed(event)
|
|||||||
call airline#update_statusline()
|
call airline#update_statusline()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:on_focus_gained()
|
||||||
|
if airline#util#focusgained_disabled()
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
unlet! w:airline_lastmode | :call <sid>airline_refresh(1)
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:on_cursor_moved()
|
function! s:on_cursor_moved()
|
||||||
if winnr() != s:active_winnr || !exists('w:airline_active')
|
if winnr() != s:active_winnr || !exists('w:airline_active')
|
||||||
call s:on_window_changed('CursorMoved')
|
call s:on_window_changed('CursorMoved')
|
||||||
@ -154,14 +161,14 @@ function! s:airline_toggle()
|
|||||||
" non-trivial number of external plugins use eventignore=all, so we need to account for that
|
" non-trivial number of external plugins use eventignore=all, so we need to account for that
|
||||||
autocmd CursorMoved * call <sid>on_cursor_moved()
|
autocmd CursorMoved * call <sid>on_cursor_moved()
|
||||||
|
|
||||||
autocmd VimResized * unlet! w:airline_lastmode | :call <sid>airline_refresh()
|
autocmd VimResized * call <sid>on_focus_gained()
|
||||||
if exists('*timer_start') && exists('*funcref')
|
if exists('*timer_start') && exists('*funcref')
|
||||||
" do not trigger FocusGained on startup, it might erase the intro screen (see #1817)
|
" do not trigger FocusGained on startup, it might erase the intro screen (see #1817)
|
||||||
" needs funcref() (needs 7.4.2137) and timers (7.4.1578)
|
" needs funcref() (needs 7.4.2137) and timers (7.4.1578)
|
||||||
let Handler=funcref('<sid>FocusGainedHandler')
|
let Handler=funcref('<sid>FocusGainedHandler')
|
||||||
let s:timer=timer_start(5000, Handler)
|
let s:timer=timer_start(5000, Handler)
|
||||||
else
|
else
|
||||||
autocmd FocusGained * unlet! w:airline_lastmode | :call <sid>airline_refresh()
|
autocmd FocusGained * call <sid>on_focus_gained()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists("##TerminalOpen")
|
if exists("##TerminalOpen")
|
||||||
@ -235,7 +242,7 @@ endfunction
|
|||||||
function! s:FocusGainedHandler(timer)
|
function! s:FocusGainedHandler(timer)
|
||||||
if exists("s:timer") && a:timer == s:timer
|
if exists("s:timer") && a:timer == s:timer
|
||||||
augroup airline
|
augroup airline
|
||||||
au FocusGained * unlet! w:airline_lastmode | :call <sid>airline_refresh()
|
au FocusGained * call s:on_focus_gained()
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
endfu
|
endfu
|
||||||
|
Loading…
x
Reference in New Issue
Block a user