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