From 68b31a4a66ec945ff299db25a8a6382cd48edf14 Mon Sep 17 00:00:00 2001 From: gh4w Date: Sun, 29 Sep 2019 02:10:13 +0200 Subject: [PATCH] output of chcp was not parsed correctly (#886) * output of chcp was not parsed correctly On Windows, when wrapping a batch command with the function s:wrap_cmds(), when calling 'chcp' to get the current code page, the code assumed that the output was in the format "active code page: XXX" (where XXX is the code page), whereas the actual output is localized (for instance, in French, the output would be: "page de code active: XXX"). The parsing of the output relied on that, and this failed for a message different from "active code page" (i.e., English). This patch changes the parsing to split the output of chcp on the colon instead of spaces. Assuming that the output is always in the format ": XXX", regardless of the locale, hopefully, this is a bit more robust. --- plug.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plug.vim b/plug.vim index 6b4caf8..bc3706c 100644 --- a/plug.vim +++ b/plug.vim @@ -353,9 +353,9 @@ if s:is_win " Copied from fzf function! s:wrap_cmds(cmds) - return map(['@echo off', 'for /f "tokens=4" %%a in (''chcp'') do set origchcp=%%a', 'chcp 65001 > nul'] + + 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'], 'v:val."\r"') + \ ['chcp !origchcp! > nul','setlocal disabledelayedexpansion'],'v:val."\r"') endfunction function! s:batchfile(cmd)