From 02af734b3ca5c3afd6d4511edd50c85354858219 Mon Sep 17 00:00:00 2001 From: gh4w Date: Sat, 28 Sep 2019 14:14:56 +0200 Subject: [PATCH] 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plug.vim b/plug.vim index 6b4caf8..e2b684d 100644 --- a/plug.vim +++ b/plug.vim @@ -353,7 +353,7 @@ 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', '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"') endfunction