3
3
" Maintainer: skywind3000 (at) gmail.com, 2016, 2017, 2018, 2019, 2020
4
4
" Homepage: http://www.vim.org/scripts/script.php?script_id=5431
5
5
"
6
- " Last Modified: 2021/03/28 22:06
6
+ " Last Modified: 2021/03/29 08:58
7
7
"
8
8
" Run shell command in background and output to quickfix:
9
9
" :AsyncRun[!] [options] {cmd} ...
@@ -1129,6 +1129,8 @@ function! s:terminal_init(opts)
1129
1129
let shell = (has (' nvim' ) == 0 )? 1 : 0
1130
1130
let pos = get (a: opts , ' pos' , ' bottom' )
1131
1131
let pos = (pos == ' background' )? ' hide' : pos
1132
+ let cwd = a: opts .cwd
1133
+ let cwd = (cwd != ' ' && isdirectory (cwd))? cwd : ' '
1132
1134
if get (a: opts , ' safe' , get (g: , ' asyncrun_term_safe' , 0 )) != 0
1133
1135
let command = s: ScriptWrite (command , 0 )
1134
1136
if stridx (command , ' ' ) >= 0
@@ -1163,8 +1165,8 @@ function! s:terminal_init(opts)
1163
1165
let opts.term_finish = ' close'
1164
1166
endif
1165
1167
if has (' patch-8.1.0230' )
1166
- if a: opts . cwd != ' '
1167
- let opts.cwd = a: opts . cwd
1168
+ if cwd != ' '
1169
+ let opts.cwd = cwd
1168
1170
endif
1169
1171
endif
1170
1172
try
@@ -1178,8 +1180,8 @@ function! s:terminal_init(opts)
1178
1180
else
1179
1181
let opts = {' stoponexit' :' term' }
1180
1182
let opts.exit_cb = function (' s:terminal_exit' )
1181
- if a: opts . cwd != ' '
1182
- let opts.cwd = a: opts . cwd
1183
+ if cwd != ' '
1184
+ let opts.cwd = cwd
1183
1185
endif
1184
1186
let jid = job_start (command , opts)
1185
1187
let bid = -1
@@ -1189,8 +1191,8 @@ function! s:terminal_init(opts)
1189
1191
else
1190
1192
let opts = {}
1191
1193
let opts.on_exit = function (' s:terminal_exit' )
1192
- if a: opts . cwd != ' '
1193
- let opts.cwd = a: opts . cwd
1194
+ if cwd != ' '
1195
+ let opts.cwd = cwd
1194
1196
endif
1195
1197
if pos != ' hide'
1196
1198
try
@@ -1246,11 +1248,11 @@ endfunc
1246
1248
function ! s: terminal_open (opts)
1247
1249
let previous = getcwd ()
1248
1250
if a: opts .cwd != ' '
1249
- call s: chdir (a: opts .cwd)
1251
+ silent ! call s: chdir (a: opts .cwd)
1250
1252
endif
1251
1253
let hr = s: terminal_init (a: opts )
1252
1254
if a: opts .cwd != ' '
1253
- call s: chdir (previous )
1255
+ silent ! call s: chdir (previous )
1254
1256
endif
1255
1257
return hr
1256
1258
endfunc
@@ -1913,7 +1915,7 @@ endfunc
1913
1915
" asyncrun - version
1914
1916
" ----------------------------------------------------------------------
1915
1917
function ! asyncrun#version ()
1916
- return ' 2.8.5 '
1918
+ return ' 2.8.6 '
1917
1919
endfunc
1918
1920
1919
1921
0 commit comments