From a50c2640b9de23b10b3927873b519930cb8a7984 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 14 May 2024 17:39:29 +0900 Subject: [PATCH] Fix Commands and Windows on Windows Use tab character with --tabstop=1 instead of non-breaking space Fix #1542 --- autoload/fzf/vim.vim | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index 6228826..c2e57c5 100755 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -1149,18 +1149,18 @@ endfunction " ------------------------------------------------------------------ " Commands " ------------------------------------------------------------------ -let s:nbs = nr2char(0xa0) +let s:tab = "\t" function! s:format_cmd(line) return substitute(a:line, '\C \([A-Z]\S*\) ', - \ '\=s:nbs.s:yellow(submatch(1), "Function").s:nbs', '') + \ '\=s:tab.s:yellow(submatch(1), "Function").s:tab', '') endfunction function! s:command_sink(lines) if len(a:lines) < 2 return endif - let cmd = matchstr(a:lines[1], s:nbs.'\zs\S*\ze'.s:nbs) + let cmd = matchstr(a:lines[1], s:tab.'\zs\S*\ze'.s:tab) if empty(a:lines[0]) call feedkeys(':'.cmd.(a:lines[1][0] == '!' ? '' : ' '), 'n') else @@ -1172,7 +1172,7 @@ let s:fmt_excmd = ' '.s:blue('%-38s', 'Statement').'%s' function! s:format_excmd(ex) let match = matchlist(a:ex, '^|:\(\S\+\)|\s*\S*\(.*\)') - return printf(s:fmt_excmd, s:nbs.match[1].s:nbs, s:strip(match[2])) + return printf(s:fmt_excmd, s:tab.match[1].s:tab, s:strip(match[2])) endfunction function! s:excmds() @@ -1210,7 +1210,7 @@ function! fzf#vim#commands(...) \ 'source': extend(extend(list[0:0], map(list[1:], 's:format_cmd(v:val)')), s:excmds()), \ 'sink*': s:function('s:command_sink'), \ 'options': '--ansi --expect '.s:conf('commands_expect', 'ctrl-x'). - \ ' --tiebreak=index --header-lines 1 -x --prompt "Commands> " -n2,3,2..3 -d'.s:nbs}, a:000) + \ ' --tiebreak=index --header-lines 1 -x --prompt "Commands> " -n2,3,2..3 --tabstop=1 -d "\t"'}, a:000) endfunction " ------------------------------------------------------------------ @@ -1382,9 +1382,9 @@ endfunction function! s:format_win(tab, win, buf) let modified = getbufvar(a:buf, '&modified') let name = bufname(a:buf) - let name = empty(name) ? s:nbs.s:nbs.'[No Name]' : ' '.s:nbs.name + let name = empty(name) ? s:tab.s:tab.'[No Name]' : ' '.s:tab.name let active = tabpagewinnr(a:tab) == a:win - return (active? s:blue('>', 'Operator') : ' ') . name . s:nbs . (modified? s:red(' [+]', 'Exception') : '') + return (active? s:blue('>', 'Operator') : ' ') . name . s:tab . (modified? s:red(' [+]', 'Exception') : '') endfunction function! s:windows_sink(line) @@ -1407,7 +1407,7 @@ function! fzf#vim#windows(...) return s:fzf('windows', { \ 'source': extend(['Tab Win Name'], lines), \ 'sink': s:function('s:windows_sink'), - \ 'options': '+m --ansi --tiebreak=begin --header-lines=1 -d'.s:nbs}, a:000) + \ 'options': '+m --ansi --tiebreak=begin --header-lines=1 --tabstop=1 -d "\t"'}, a:000) endfunction " ------------------------------------------------------------------