Skip to content

Commit

Permalink
Add optional argument winid for vista#finder#fzf#sink()
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Sep 17, 2020
1 parent 7f97d30 commit 7972a7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions autoload/vista/finder/fzf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,18 @@ function! vista#finder#fzf#extract(line) abort
return [lnum, tag]
endfunction

function! vista#finder#fzf#sink(line) abort
" Optional argument: winid for the origin tags window
function! vista#finder#fzf#sink(line, ...) abort
let [lnum, tag] = vista#finder#fzf#extract(a:line)
let col = stridx(g:vista.source.line(lnum), tag)
let col = col == -1 ? 1 : col + 1
call vista#source#GotoWin()
if a:0 > 0
if win_getid() != a:1
noautocmd call win_gotoid(a:1)
endif
else
call vista#source#GotoWin()
endif
call cursor(lnum, col)
normal! zz
call call('vista#util#Blink', get(g:, 'vista_blink', [2, 100]))
Expand Down
2 changes: 1 addition & 1 deletion autoload/vista/source.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
if exists('*bufwinid')
function! s:GotoSourceWindow() abort
let winid = g:vista.source.get_winid()
if winid != -1
if winid != -1 && win_getid() != winid
noautocmd call win_gotoid(winid)
else
return vista#error#('Cannot find the source window id')
Expand Down

0 comments on commit 7972a7c

Please sign in to comment.