mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-01-08 20:43:32 +08:00
@@ -352,15 +352,43 @@ endfunction
|
||||
" ------------------------------------------------------------------
|
||||
" Buffers
|
||||
" ------------------------------------------------------------------
|
||||
function! s:find_open_window(b)
|
||||
let [tcur, tcnt] = [tabpagenr() - 1, tabpagenr('$')]
|
||||
for toff in range(0, tabpagenr('$') - 1)
|
||||
let t = (tcur + toff) % tcnt + 1
|
||||
let buffers = tabpagebuflist(t)
|
||||
for w in range(1, len(buffers))
|
||||
let b = buffers[w - 1]
|
||||
if b == a:b
|
||||
return [t, w]
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
return [0, 0]
|
||||
endfunction
|
||||
|
||||
function! s:jump(t, w)
|
||||
execute 'normal!' a:t.'gt'
|
||||
execute a:w.'wincmd w'
|
||||
endfunction
|
||||
|
||||
function! s:bufopen(lines)
|
||||
if len(a:lines) < 2
|
||||
return
|
||||
endif
|
||||
let b = matchstr(a:lines[1], '\[\zs[0-9]*\ze\]')
|
||||
if empty(a:lines[0]) && get(g:, 'fzf_buffers_jump')
|
||||
let [t, w] = s:find_open_window(b)
|
||||
if t
|
||||
call s:jump(t, w)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
let cmd = get(get(g:, 'fzf_action', s:default_action), a:lines[0], '')
|
||||
if !empty(cmd)
|
||||
execute 'silent' cmd
|
||||
endif
|
||||
execute 'buffer' matchstr(a:lines[1], '\[\zs[0-9]*\ze\]')
|
||||
execute 'buffer' b
|
||||
endfunction
|
||||
|
||||
function! s:format_buffer(b)
|
||||
@@ -693,8 +721,7 @@ endfunction
|
||||
|
||||
function! s:windows_sink(line)
|
||||
let list = matchlist(a:line, '\([ 0-9]*\):\([ 0-9]*\)')
|
||||
execute 'normal!' list[1].'gt'
|
||||
execute list[2].'wincmd w'
|
||||
call s:jump(list[1], list[2])
|
||||
endfunction
|
||||
|
||||
function! fzf#vim#windows(...)
|
||||
|
||||
Reference in New Issue
Block a user