mirror of
https://github.com/preservim/tagbar.git
synced 2025-02-13 05:04:34 +08:00
Open previewwin relative to Tagbar win
This commit is contained in:
parent
b4a5800f72
commit
87bbb46e95
|
@ -972,7 +972,7 @@ function! s:CreateAutocommands() abort
|
|||
autocmd CursorMoved __Tagbar__ nested call s:ShowInPreviewWin()
|
||||
endif
|
||||
|
||||
autocmd BufEnter * nested call s:QuitIfOnlyWindow()
|
||||
autocmd WinEnter * nested call s:QuitIfOnlyWindow()
|
||||
autocmd WinEnter * if bufwinnr('__Tagbar__') == -1 |
|
||||
\ call s:ShrinkIfExpanded() |
|
||||
\ endif
|
||||
|
@ -3021,6 +3021,25 @@ function! s:ShowInPreviewWin() abort
|
|||
return
|
||||
endif
|
||||
|
||||
" Check whether the preview window is already open and open it if not.
|
||||
" This has to be done before the :psearch below so the window is relative
|
||||
" to the Tagbar window.
|
||||
let pwin_open = 0
|
||||
for win in range(1, winnr('$'))
|
||||
if getwinvar(win, '&previewwindow')
|
||||
let pwin_open = 1
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
|
||||
if !pwin_open
|
||||
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
|
||||
let s:pwin_by_tagbar = 1
|
||||
endif
|
||||
|
||||
" Use psearch instead of pedit since pedit essentially reloads the file
|
||||
" and creates an empty undo entry. psearch has to be called from the file
|
||||
" window, and since we only want matches in the current file we disable
|
||||
|
@ -3031,15 +3050,10 @@ function! s:ShowInPreviewWin() abort
|
|||
call s:GotoFileWindow(taginfo.fileinfo, 1)
|
||||
let include_save = &include
|
||||
set include=
|
||||
silent! execute g:tagbar_previewwin_pos . ' ' .
|
||||
\ taginfo.fields.line . ',$psearch! /' . taginfo.pattern . '/'
|
||||
silent! execute taginfo.fields.line . ',$psearch! /' . taginfo.pattern . '/'
|
||||
let &include = include_save
|
||||
call s:goto_tagbar(1)
|
||||
|
||||
" Remember that the preview window was opened by Tagbar so we can safely
|
||||
" close it by ourselves
|
||||
let s:pwin_by_tagbar = 1
|
||||
|
||||
call s:goto_win('P', 1)
|
||||
normal! zv
|
||||
normal! zz
|
||||
|
|
Loading…
Reference in New Issue
Block a user