Skip to content

Commit

Permalink
[vim] Encode list source to codepage (#1794)
Browse files Browse the repository at this point in the history
  • Loading branch information
janlazo authored and junegunn committed Dec 16, 2019
1 parent aa0e10e commit 5da8bbf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plugin/fzf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,17 @@ if s:is_win
" Use utf-8 for fzf.vim commands
" Return array of shell commands for cmd.exe
let s:codepage = libcallnr('kernel32.dll', 'GetACP', 0)
function! s:enc_to_cp(str)
return iconv(a:str, &encoding, 'cp'.s:codepage)
endfunction
function! s:wrap_cmds(cmds)
return map([
\ '@echo off',
\ 'setlocal enabledelayedexpansion']
\ + (has('gui_running') ? ['set TERM= > nul'] : [])
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
\ + ['endlocal'],
\ printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage))
\ '<SID>enc_to_cp(v:val."\r")')
endfunction
else
let s:term_marker = ";#FZF"
Expand All @@ -69,6 +72,10 @@ else
function! s:wrap_cmds(cmds)
return a:cmds
endfunction

function! s:enc_to_cp(str)
return a:str
endfunction
endif

function! s:shellesc_cmd(arg)
Expand Down Expand Up @@ -384,7 +391,7 @@ try
let prefix = '( '.source.' )|'
elseif type == 3
let temps.input = s:fzf_tempname()
call writefile(source, temps.input)
call writefile(map(source, '<SID>enc_to_cp(v:val)'), temps.input)
let prefix = (s:is_win ? 'type ' : 'cat ').fzf#shellescape(temps.input).'|'
else
throw 'Invalid source type'
Expand Down

0 comments on commit 5da8bbf

Please sign in to comment.