From 849b76be90a2c5a13fd9943b2b76d77a9b6ebc0f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 3 Oct 2019 21:19:11 -0400 Subject: [PATCH] Fix chcp parsing for the current codepage (#888) Relying on delimiters or token positions is fragile. Last value of 'chcp' output is always a number. --- plug.vim | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plug.vim b/plug.vim index bc3706c..2571fe3 100644 --- a/plug.vim +++ b/plug.vim @@ -353,9 +353,15 @@ if s:is_win " Copied from fzf function! s:wrap_cmds(cmds) - return map(['@echo off','setlocal enabledelayedexpansion','for /f "delims=: tokens=2" %%a in (''chcp'') do set origchcp=%%a','set origchcp=!origchcp: =!','chcp 65001 > nul'] + - \ (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) + - \ ['chcp !origchcp! > nul','setlocal disabledelayedexpansion'],'v:val."\r"') + return map([ + \ '@echo off', + \ 'setlocal enabledelayedexpansion', + \ 'for /f "tokens=*" %%a in (''chcp'') do for %%b in (%%a) do set origchcp=%%b', + \ 'chcp 65001 > nul' + \ ] + \ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) + \ + ['chcp !origchcp! > nul', 'endlocal'], + \ 'v:val."\r"') endfunction function! s:batchfile(cmd)