From fcc798e99ef529d17f5f46f6664cf89435d46c40 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 29 Apr 2016 10:30:48 +0900 Subject: [PATCH] Addendum fix for #136 - Apply --tabstop=1 to line completion - Fix incorrect --nth Related: #139, #136 --- autoload/fzf/vim.vim | 8 +++++--- autoload/fzf/vim/complete.vim | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index 3e3ebc3..4268970 100644 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -253,14 +253,16 @@ function! fzf#vim#_lines(all) \ '(!a:all && empty(v:val)) ? "" : printf(s:blue("%2d\t", "TabLine")."%s".s:yellow("\t%4d ", "LineNr")."\t%s", b, bufname, v:key + 1, v:val)'), \ 'a:all || !empty(v:val)')) endfor - return extend(cur, rest) + return [display_bufnames, extend(cur, rest)] endfunction function! fzf#vim#lines(...) + let [display_bufnames, lines] = fzf#vim#_lines(1) + let nth = display_bufnames ? 3 : 2 return s:fzf(fzf#vim#wrap({ - \ 'source': fzf#vim#_lines(1), + \ 'source': lines, \ 'sink*': s:function('s:line_handler'), - \ 'options': '+m --tiebreak=index --prompt "Lines> " --ansi --extended --nth=3.. --reverse --tabstop=1' + \ 'options': '+m --tiebreak=index --prompt "Lines> " --ansi --extended --nth='.nth.'.. --reverse --tabstop=1' \}), a:000) endfunction diff --git a/autoload/fzf/vim/complete.vim b/autoload/fzf/vim/complete.vim index 71e700b..2591adc 100644 --- a/autoload/fzf/vim/complete.vim +++ b/autoload/fzf/vim/complete.vim @@ -141,10 +141,12 @@ endfunction function! fzf#vim#complete#line(...) + let [display_bufnames, lines] = fzf#vim#_lines(0) + let nth = display_bufnames ? 4 : 3 return fzf#vim#complete(s:extend({ \ 'prefix': '^.*$', - \ 'source': fzf#vim#_lines(0), - \ 'options': '--tiebreak=index --ansi --nth 4..', + \ 'source': lines, + \ 'options': '--tiebreak=index --ansi --nth '.nth.'.. --tabstop=1', \ 'reducer': s:function('s:reduce_line')}, get(a:000, 0, g:fzf#vim#default_layout))) endfunction