diff --git a/autoload/gitgutter/utility.vim b/autoload/gitgutter/utility.vim index bacbf22..81f4a03 100644 --- a/autoload/gitgutter/utility.vim +++ b/autoload/gitgutter/utility.vim @@ -1,5 +1,5 @@ function! gitgutter#utility#supports_overscore_sign() - if s:windows() + if gitgutter#utility#windows() return &encoding ==? 'utf-8' else return &termencoding ==? &encoding || &termencoding == '' @@ -161,7 +161,7 @@ function! s:set_path(bufnr, path) endfunction function! gitgutter#utility#cd_cmd(bufnr, cmd) abort - let cd = s:unc_path(a:bufnr) ? 'pushd' : (s:windows() ? 'cd /d' : 'cd') + let cd = s:unc_path(a:bufnr) ? 'pushd' : (gitgutter#utility#windows() ? 'cd /d' : 'cd') return cd.' '.s:dir(a:bufnr).' && '.a:cmd endfunction @@ -205,6 +205,6 @@ function! s:strip_trailing_new_line(line) abort return substitute(a:line, '\n$', '', '') endfunction -function! s:windows() +function! gitgutter#utility#windows() return has('win64') || has('win32') || has('win16') endfunction diff --git a/plugin/gitgutter.vim b/plugin/gitgutter.vim index 3d64514..c2aaf2a 100644 --- a/plugin/gitgutter.vim +++ b/plugin/gitgutter.vim @@ -76,6 +76,14 @@ call gitgutter#highlight#define_sign_column_highlight() call gitgutter#highlight#define_highlights() call gitgutter#highlight#define_signs() +" Prevent infinite loop where: +" - executing a job in the foreground launches a new window which takes the focus; +" - when the job finishes, focus returns to gvim; +" - the FocusGained event triggers a new job (see below). +if gitgutter#utility#windows() && !gitgutter#async#available() + set noshelltemp +endif + " }}} " Primary functions {{{