diff --git a/autoload/sy.vim b/autoload/sy.vim index 1b0c3db..2e95f08 100644 --- a/autoload/sy.vim +++ b/autoload/sy.vim @@ -35,13 +35,14 @@ function! sy#start() abort if !exists('b:sy') || b:sy.path != sy_path call sy#verbose('Register new file.') let b:sy = { - \ 'path' : sy_path, - \ 'buffer': bufnr(''), - \ 'active': 0, - \ 'vcs' : 'unknown', - \ 'hunks' : [], - \ 'signid': 0x100, - \ 'stats' : [-1, -1, -1] } + \ 'path' : sy_path, + \ 'buffer': bufnr(''), + \ 'active': 0, + \ 'detecting': 0, + \ 'vcs' : 'unknown', + \ 'hunks' : [], + \ 'signid': 0x100, + \ 'stats' : [-1, -1, -1] } if get(g:, 'signify_disable_by_default') call sy#verbose('Disabled by default.') return @@ -60,8 +61,12 @@ function! sy#start() abort call sy#verbose('Redetecting VCS.') call sy#repo#detect(1) else - call sy#verbose('No VCS found. Disabling.') - call sy#disable() + if get(b:sy, 'detecting') + call sy#verbose('Detection is already in progress.') + else + call sy#verbose('No VCS found. Disabling.') + call sy#disable() + endif endif else let job_id = get(b:, 'sy_job_id_'.b:sy.vcs) diff --git a/autoload/sy/repo.vim b/autoload/sy/repo.vim index 4bd1939..ebff627 100644 --- a/autoload/sy/repo.vim +++ b/autoload/sy/repo.vim @@ -16,6 +16,7 @@ function! sy#repo#detect(do_register) abort endif for vcs in vcs_list + let b:sy.detecting += 1 call sy#repo#get_diff_start(vcs, a:do_register) endfor endfunction @@ -61,6 +62,8 @@ function! s:job_exit(bufnr, vcs, exitval, diff, do_register) abort if empty(sy) call sy#verbose(printf('No b:sy found for %s', bufname(a:bufnr)), a:vcs) return + elseif sy.vcs == 'unknown' && sy.active + let sy.detecting -= 1 endif call sy#repo#get_diff_{a:vcs}(sy, a:exitval, a:diff, a:do_register) call setbufvar(a:bufnr, 'sy_job_id_'.a:vcs, 0)