Fix Commands and Windows on Windows

Use tab character with --tabstop=1 instead of non-breaking space

Fix #1542
This commit is contained in:
Junegunn Choi
2024-05-14 17:39:29 +09:00
parent d91dd754a9
commit a50c2640b9

View File

@@ -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
" ------------------------------------------------------------------