@@ -116,6 +116,10 @@ let s:TYPE = {
116
116
let s: loaded = get (s: , ' loaded' , {})
117
117
let s: triggers = get (s: , ' triggers' , {})
118
118
119
+ function ! s: is_powershell (shell )
120
+ return a: shell = ~# ' powershell\(\.exe\)\?$' || a: shell = ~# ' pwsh\(\.exe\)\?$'
121
+ endfunction
122
+
119
123
function ! s: isabsolute (dir ) abort
120
124
return a: dir = ~# ' ^/' || (has (' win32' ) && a: dir = ~? ' ^\%(\\\|[A-Z]:\)' )
121
125
endfunction
@@ -263,7 +267,7 @@ function! s:define_commands()
263
267
endif
264
268
if has (' win32' )
265
269
\ && &shellslash
266
- \ && (&shell = ~# ' cmd\(\.exe\)\?$' || &shell = ~# ' powershell\(\.exe\)\?$ ' )
270
+ \ && (&shell = ~# ' cmd\(\.exe\)\?$' || s: is_powershell ( &shell ) )
267
271
return s: err (' vim-plug does not support shell, ' . &shell . ' , when shellslash is set.' )
268
272
endif
269
273
if ! has (' nvim' )
@@ -503,7 +507,7 @@ if s:is_win
503
507
let batchfile = s: plug_tempname ().' .bat'
504
508
call writefile (s: wrap_cmds (a: cmd ), batchfile)
505
509
let cmd = plug#shellescape (batchfile, {' shell' : &shell , ' script' : 0 })
506
- if &shell = ~# ' powershell\(\.exe\)\?$ '
510
+ if s: is_powershell ( &shell )
507
511
let cmd = ' & ' . cmd
508
512
endif
509
513
return [batchfile, cmd]
@@ -935,7 +939,7 @@ function! s:prepare(...)
935
939
call s: new_window ()
936
940
endif
937
941
938
- nnoremap <silent> <buffer> q :if b:plug_preview==1 <bar> pc <bar> endif <bar> bd <cr>
942
+ nnoremap <silent> <buffer> q :call <SID> close_pane() <cr>
939
943
if a: 0 == 0
940
944
call s: finish_bindings ()
941
945
endif
@@ -957,6 +961,15 @@ function! s:prepare(...)
957
961
endif
958
962
endfunction
959
963
964
+ function ! s: close_pane ()
965
+ if b: plug_preview == 1
966
+ pc
967
+ let b: plug_preview = -1
968
+ else
969
+ bd
970
+ endif
971
+ endfunction
972
+
960
973
function ! s: assign_name ()
961
974
" Assign buffer name
962
975
let prefix = ' [Plugins]'
@@ -975,7 +988,7 @@ function! s:chsh(swap)
975
988
set shell = sh
976
989
endif
977
990
if a: swap
978
- if & shell = ~# ' powershell\(\.exe\)\?$ ' || &shell = ~# ' pwsh$ '
991
+ if s: is_powershell ( &shell )
979
992
let &shellredir = ' 2>&1 | Out-File -Encoding UTF8 %s'
980
993
elseif &shell = ~# ' sh' || &shell = ~# ' cmd\(\.exe\)\?$'
981
994
set shellredir = >% s \ 2 >&1
@@ -2216,7 +2229,7 @@ function! plug#shellescape(arg, ...)
2216
2229
let script = get (opts, ' script' , 1 )
2217
2230
if shell = ~# ' cmd\(\.exe\)\?$'
2218
2231
return s: shellesc_cmd (a: arg , script )
2219
- elseif shell = ~# ' powershell\(\.exe\)\?$ ' || shell = ~# ' pwsh$ '
2232
+ elseif s: is_powershell ( shell )
2220
2233
return s: shellesc_ps1 (a: arg )
2221
2234
endif
2222
2235
return s: shellesc_sh (a: arg )
@@ -2268,7 +2281,7 @@ function! s:system(cmd, ...)
2268
2281
return system (a: cmd )
2269
2282
endif
2270
2283
let cmd = join (map (copy (a: cmd ), ' plug#shellescape(v:val, {"shell": &shell, "script": 0})' ))
2271
- if &shell = ~# ' powershell\(\.exe\)\?$ '
2284
+ if s: is_powershell ( &shell )
2272
2285
let cmd = ' & ' . cmd
2273
2286
endif
2274
2287
else
0 commit comments