diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 81fe278..0d24b82 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -191,8 +191,10 @@ function! s:update_untracked() " 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 s:get_vcs_untracked_async(l:config, l:file) + elseif has('nvim') + call airline#util#system(l:config, l:file) else - let output = airline#util#system(l:config.cmd . shellescape(l:file)) + let output = airline#util#system(l:config, l:file) if output =~? ('^' . l:config.untracked_mark) let l:config.untracked[l:file] = get(g:, 'airline#extensions#branch#notexists', g:airline_symbols.notexists) else diff --git a/autoload/airline/util.vim b/autoload/airline/util.vim index 3f94086..ea4c983 100644 --- a/autoload/airline/util.vim +++ b/autoload/airline/util.vim @@ -94,20 +94,31 @@ if has('nvim') function! s:system_job_handler(job_id, data, event) dict if a:event == 'stdout' let self.buf .= join(a:data) + else " on_exit handler + if self.buf =~? ('^' . self.cfg['untracked_mark']) + let self.cfg.untracked[self.file] = get(g:, 'airline#extensions#branch#notexists', g:airline_symbols.notexists) + else + let self.cfg.untracked[self.file] = '' + endif endif endfunction - function! airline#util#system(cmd) + function! airline#util#system(cfg, file) let l:config = { \ 'buf': '', + \ 'cfg': a:cfg, + \ 'file': a:file, + \ 'cwd': fnamemodify(a:file, ':p:h'), \ 'on_stdout': function('s:system_job_handler'), + \ 'on_exit': function('s:system_job_handler') \ } - let l:id = jobstart(a:cmd, l:config) + let cmd = a:cfg.cmd . shellescape(a:file) + let l:id = jobstart(cmd, l:config) if l:id < 1 - return system(a:cmd) + return system(cmd) + else + return '' endif - call jobwait([l:id]) - return l:config.buf endfunction else function! airline#util#system(cmd)