mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-06 20:54:28 +08:00
[fzf-complete-line] Exclude empty lines
This commit is contained in:
@@ -154,21 +154,23 @@ function! s:line_handler(lines)
|
||||
normal! ^zz
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#_lines()
|
||||
function! fzf#vim#_lines(all)
|
||||
let cur = []
|
||||
let rest = []
|
||||
let buf = bufnr('')
|
||||
for b in s:buflisted()
|
||||
call extend(b == buf ? cur : rest,
|
||||
\ map(getbufline(b, 1, "$"),
|
||||
\ 'printf("[%s]\t%s:\t%s", s:blue(b), s:yellow(v:key + 1), v:val)'))
|
||||
\ filter(
|
||||
\ map(getbufline(b, 1, "$"),
|
||||
\ '(!a:all && empty(v:val)) ? "" : printf("[%s]\t%s:\t%s", s:blue(b), s:yellow(v:key + 1), v:val)'),
|
||||
\ 'a:all || !empty(v:val)'))
|
||||
endfor
|
||||
return extend(cur, rest)
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#lines(...)
|
||||
call s:fzf({
|
||||
\ 'source': fzf#vim#_lines(),
|
||||
\ 'source': fzf#vim#_lines(1),
|
||||
\ 'sink*': function('s:line_handler'),
|
||||
\ 'options': '+m --tiebreak=index --prompt "Lines> " --ansi --extended --nth=3..'.s:expect()
|
||||
\}, a:000)
|
||||
|
||||
@@ -121,7 +121,7 @@ endfunction
|
||||
function! fzf#vim#complete#line(...)
|
||||
return fzf#vim#complete(extend({
|
||||
\ 'prefix': '^.*$',
|
||||
\ 'source': fzf#vim#_lines(),
|
||||
\ 'source': fzf#vim#_lines(0),
|
||||
\ 'options': '--tiebreak=index --ansi --nth 3..',
|
||||
\ 'reducer': function('s:reduce_line')}, get(a:000, 0, g:fzf#vim#default_layout)))
|
||||
endfunction
|
||||
|
||||
Reference in New Issue
Block a user