From 941341d085a26c007a71c45290da9f32f9d0f221 Mon Sep 17 00:00:00 2001 From: Christian Brabandt Date: Wed, 24 Apr 2019 13:25:31 +0200 Subject: [PATCH] branch: simplify async logic a bit --- autoload/airline/async.vim | 10 ++++++++++ autoload/airline/extensions/branch.vim | 17 ++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/autoload/airline/async.vim b/autoload/airline/async.vim index 6dcabf6..1e1ded6 100644 --- a/autoload/airline/async.vim +++ b/autoload/airline/async.vim @@ -123,6 +123,16 @@ if v:version >= 800 && has("job") let s:po_jobs[a:file] = id endfunction + function! airline#async#vcs_untracked(config, file, vcs) + if g:airline#init#vim_async + " Vim 8 with async support + noa call airline#async#vim_vcs_untracked(a:config, a:file) + else + " nvim async or vim without job-feature + noa call airline#async#nvim_vcs_untracked(a:config, a:file, a:vcs) + endif + endfunction + function! airline#async#vim_vcs_untracked(config, file) if g:airline#init#is_windows && &shell =~ 'cmd' let cmd = a:config['cmd'] . shellescape(a:file) diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 1aeba8d..33c4a6b 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -194,17 +194,12 @@ function! s:update_untracked() for vcs in keys(s:vcs_config) let config = s:vcs_config[vcs] - if g:airline#init#vim_async - " Note that asynchronous update updates s:vcs_config only, and only - " s:update_untracked updates b:buffer_vcs_config. If s:vcs_config is - " invalidated again before s:update_untracked is called, then we lose the - " result of the previous call, i.e. the head string is not updated. It - " doesn't happen often in practice, so we let it be. - noa call airline#async#vim_vcs_untracked(config, file) - else - " nvim async or vim without job-feature - noa call airline#async#nvim_vcs_untracked(config, file, vcs) - endif + " Note that asynchronous update updates s:vcs_config only, and only + " s:update_untracked updates b:buffer_vcs_config. If s:vcs_config is + " invalidated again before s:update_untracked is called, then we lose the + " result of the previous call, i.e. the head string is not updated. It + " doesn't happen often in practice, so we let it be. + call airline#async#vcs_untracked(config, file, vcs) endfor endfunction