From 004af251507ade4e86e308a58ca9d69229a0dcec Mon Sep 17 00:00:00 2001 From: Michael Budde Date: Thu, 16 Nov 2017 07:11:27 +0100 Subject: [PATCH] [GitFiles] Support files with special characters (#500) By default git will quote filenames that contain special characters. From the git help on the `core.quotepath` config: > The commands that output paths (e.g. `ls-files`, `diff`), when not given > the `-z` option, will quote "unusual" characters in the pathname by > enclosing the pathname in a double-quote pair and with backslashes the > same way strings in C source code are quoted. If this variable is set > to false, the bytes higher than 0x80 are not quoted but output as > verbatim. Note that double quote, backslash and control characters are > always quoted without `-z` regardless of the setting of this variable. This quoting behaviour means that GitFiles cannot be used to open files that contain any special characters. Fix this by using the `-z` option to `ls-files` together with the `--read0` option on fzf. --- autoload/fzf/vim.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index 55d3b69..4c69f9d 100644 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -511,9 +511,9 @@ function! fzf#vim#gitfiles(args, ...) endif if a:args != '?' return s:fzf('gfiles', { - \ 'source': 'git ls-files '.a:args.(s:is_win ? '' : ' | uniq'), + \ 'source': 'git ls-files -z '.a:args.(s:is_win ? '' : ' | uniq'), \ 'dir': root, - \ 'options': '-m --prompt "GitFiles> "' + \ 'options': '--read0 -m --prompt "GitFiles> "' \}, a:000) endif