Skip to content

Commit 7a752fb

Browse files
committed
[neovim] Use powershell to handle single-quote escaping
1 parent 5979c87 commit 7a752fb

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

plugin/fzf.vim

+9-3
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,18 @@ function! s:execute(dict, command, use_height, temps) abort
493493
if has('nvim') && s:is_win
494494
let s:dict = a:dict
495495
let s:temps = a:temps
496+
let s:powershell = ['powershell', '-NoProfile', '-ExecutionPolicy', 'RemoteSigned', '-Command']
496497
let fzf = {}
497498
function! fzf.on_exit(job_id, exit_status, event) dict
499+
let temps_old = s:temps.result
500+
let s:temps.result = tempname()
501+
let ps_utf8_fmt = 'Get-Content -Encoding utf8 %s | Add-Content -Encoding utf8 %s'
502+
let ps_utf8 = printf(ps_utf8_fmt, temps_old, s:temps.result)
503+
call system(s:powershell + [ps_utf8])
498504
let lines = s:collect(s:temps)
499505
call s:callback(s:dict, lines)
500506
endfunction
501-
let cmd = ['cmd', '/C', 'start', '/WAIT', 'cmd', '/C', command]
507+
let cmd = ['cmd', '/C', 'start', '/WAIT'] + s:powershell + [command]
502508
call jobstart(cmd, fzf)
503509
return []
504510
endif
@@ -715,7 +721,7 @@ function! s:shortpath()
715721
let short = pathshorten(fzf#fnamemodify(fzf#getcwd(), ':~:.'))
716722
let slash = s:is_win ? '\' : '/'
717723
let path = empty(short) ? '~'.slash : short . (short =~ '/$' ? '' : slash)
718-
return (s:is_win && !has('nvim')) ? escape(path, ' \') : path
724+
return (s:is_win) ? escape(path, ' \') : path
719725
endfunction
720726

721727
function! s:cmd(bang, ...) abort
@@ -726,7 +732,7 @@ function! s:cmd(bang, ...) abort
726732
if s:is_win
727733
let opts.dir = substitute(opts.dir, '/', '\\', 'g')
728734
endif
729-
let dir = (s:is_win && !has('nvim')) ? escape(opts.dir, ' \') : opts.dir
735+
let dir = (s:is_win) ? escape(opts.dir, ' \') : opts.dir
730736
else
731737
let dir = s:shortpath()
732738
endif

0 commit comments

Comments
 (0)