mirror of
https://github.com/gryf/tagbar.git
synced 2025-12-17 11:30:28 +01:00
Prevent temporary window creation on Windows (#611)
Co-authored-by: skywind3000 <skywind3000@163.com> Co-authored-by: Caleb Maclennan <caleb@alerque.com>
This commit is contained in:
@@ -2871,6 +2871,39 @@ function! s:EscapeCtagsCmd(ctags_bin, args, ...) abort
|
||||
return ctags_cmd
|
||||
endfunction
|
||||
|
||||
" run shell command in a proper way: prevent temporary window creation
|
||||
function! s:run_system(cmd, version) abort
|
||||
if has('win32') && !has('nvim') && a:version > 0 && (has('python3') || has('python2'))
|
||||
if a:version == 3 && has('python3')
|
||||
let pyx = 'py3 '
|
||||
let python_eval = 'py3eval'
|
||||
elseif a:version == 2 && has('python2')
|
||||
let pyx = 'py2 '
|
||||
let python_eval = 'pyeval'
|
||||
else
|
||||
let pyx = 'pyx '
|
||||
let python_eval = 'pyxeval'
|
||||
endif
|
||||
let l:pc = 0
|
||||
exec pyx . 'import subprocess, vim'
|
||||
exec pyx . '__argv = {"args":vim.eval("a:cmd"), "shell":True}'
|
||||
exec pyx . '__argv["stdout"] = subprocess.PIPE'
|
||||
exec pyx . '__argv["stderr"] = subprocess.STDOUT'
|
||||
exec pyx . '__pp = subprocess.Popen(**__argv)'
|
||||
exec pyx . '__return_text = __pp.stdout.read()'
|
||||
exec pyx . '__pp.stdout.close()'
|
||||
exec pyx . '__return_code = __pp.wait()'
|
||||
exec 'let l:hr = '. python_eval .'("__return_text")'
|
||||
exec 'let l:pc = '. python_eval .'("__return_code")'
|
||||
let s:shell_error = l:pc
|
||||
return l:hr
|
||||
endif
|
||||
let hr = system(a:cmd)
|
||||
let s:shell_error = v:shell_error
|
||||
return hr
|
||||
endfunction
|
||||
|
||||
|
||||
" s:ExecuteCtags() {{{2
|
||||
" Execute ctags with necessary shell settings
|
||||
" Partially based on the discussion at
|
||||
@@ -2908,7 +2941,8 @@ function! s:ExecuteCtags(ctags_cmd) abort
|
||||
call tagbar#debug#log('Exit code: ' . v:shell_error)
|
||||
redraw!
|
||||
else
|
||||
silent let ctags_output = system(a:ctags_cmd)
|
||||
let py_version = get(g:, 'tagbar_python', 1)
|
||||
silent let ctags_output = s:run_system(a:ctags_cmd, py_version)
|
||||
endif
|
||||
|
||||
if &shell =~? 'cmd\.exe'
|
||||
|
||||
Reference in New Issue
Block a user