From 64e935fe5812d3b7022aba1dee63ec9f7456b02f Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Tue, 14 Oct 2014 15:59:29 +1300 Subject: [PATCH] Small preview window improvements, ref #161 --- autoload/tagbar.vim | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 3845651..c06e675 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1854,10 +1854,9 @@ function! s:CloseWindow() abort " Close the preview window if it was opened by us if s:pwin_by_tagbar pclose + let tagbarwinnr = bufwinnr('__Tagbar__') endif - let tagbarbufnr = winbufnr(tagbarwinnr) - if winnr() == tagbarwinnr if winbufnr(2) != -1 " Other windows are open, only close the tagbar one @@ -3018,7 +3017,8 @@ endfunction " s:ShowInPreviewWin() {{{2 function! s:ShowInPreviewWin() abort - let taginfo = s:GetTagInfo(line('.'), 1) + let pos = getpos('.') + let taginfo = s:GetTagInfo(pos[1], 1) if empty(taginfo) || !taginfo.isNormalTag() return @@ -3039,7 +3039,7 @@ function! s:ShowInPreviewWin() abort endfor if !pwin_open - silent! execute + silent execute \ g:tagbar_previewwin_pos . ' pedit ' . taginfo.fileinfo.fpath " Remember that the preview window was opened by Tagbar so we can " safely close it by ourselves @@ -3061,8 +3061,9 @@ function! s:ShowInPreviewWin() abort call s:goto_win('P', 1) normal! zv normal! zz - call s:goto_markedwin() + call s:goto_markedwin(1) call s:goto_tagbar(1) + call cursor(pos[1], pos[2]) endfunction " s:ShowPrototype() {{{2 @@ -3867,9 +3868,10 @@ endfunction " s:goto_markedwin() {{{2 " Go to a previously marked window and delete the mark. -function! s:goto_markedwin() abort +function! s:goto_markedwin(...) abort + let noauto = a:0 > 0 ? a:1 : 0 for window in range(1, winnr('$')) - call s:goto_win(window) + call s:goto_win(window, noauto) if exists('w:tagbar_mark') unlet w:tagbar_mark break