[BLines] Fix incorrect line numbers when run with query (#694)

This commit is contained in:
Junegunn Choi
2018-09-08 02:39:46 +09:00
parent aedd47be21
commit 8fa84e0fdf

View File

@@ -406,7 +406,12 @@ endfunction
function! s:buffer_lines(query)
let linefmt = s:yellow(" %4d ", "LineNr")."\t%s"
return map(empty(a:query) ? getline(1, "$") : filter(getline(1, "$"), 'v:val =~ "'.a:query.'"'), 'printf(linefmt, v:key + 1, v:val)')
let fmtexpr = 'printf(linefmt, v:key + 1, v:val)'
let lines = getline(1, '$')
if empty(a:query)
return map(lines, fmtexpr)
end
return filter(map(lines, 'v:val =~ a:query ? '.fmtexpr.' : ""'), 'len(v:val)')
endfunction
function! fzf#vim#buffer_lines(...)