From 7e35a40715479abc87ccc344df46952a8a3260b5 Mon Sep 17 00:00:00 2001 From: Martin Vuille Date: Sat, 24 Sep 2016 17:45:07 -0400 Subject: [PATCH 1/5] Separate shared and per-tagbar instance data --- autoload/tagbar.vim | 72 ++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 5b9d10b..e8a5e74 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1572,7 +1572,7 @@ endfunction " s:KindheaderTag.toggleFold() {{{3 function! s:KindheaderTag.toggleFold() abort dict - let fileinfo = s:known_files.getCurrent(0) + let fileinfo = s:state.getCurrent(0) let fileinfo.kindfolds[self.short] = !fileinfo.kindfolds[self.short] endfunction @@ -1702,15 +1702,14 @@ function! s:FileInfo.closeKindFold(kind) abort dict let self.kindfolds[a:kind.short] = 1 endfunction -" Known files {{{2 -let s:known_files = { +" Per-tagbar instance state {{{2 +let s:state = { \ '_current' : {}, \ '_paused' : {}, - \ '_files' : {} \ } -" s:known_files.getCurrent() {{{3 -function! s:known_files.getCurrent(forcecurrent) abort dict +" s:state.getCurrent() {{{3 +function! s:state.getCurrent(forcecurrent) abort dict if !s:paused || a:forcecurrent return self._current else @@ -1718,16 +1717,21 @@ function! s:known_files.getCurrent(forcecurrent) abort dict endif endfunction -" s:known_files.setCurrent() {{{3 -function! s:known_files.setCurrent(fileinfo) abort dict +" s:state.setCurrent() {{{3 +function! s:state.setCurrent(fileinfo) abort dict let self._current = a:fileinfo endfunction -" s:known_files.setPaused() {{{3 -function! s:known_files.setPaused() abort dict +" s:state.setPaused() {{{3 +function! s:state.setPaused() abort dict let self._paused = self._current endfunction +" Known files {{{2 +let s:known_files = { + \ '_files' : {} +\ } + " s:known_files.get() {{{3 function! s:known_files.get(fname) abort dict return get(self._files, a:fname, {}) @@ -1934,7 +1938,7 @@ function! s:CloseWindow() abort if winbufnr(2) != -1 " Other windows are open, only close the tagbar one - let curfile = s:known_files.getCurrent(0) + let curfile = s:state.getCurrent(0) close @@ -2036,7 +2040,7 @@ endfunction " the current file after startup. function! s:CorrectFocusOnStartup() abort if bufwinnr('__Tagbar__') != -1 && !g:tagbar_autofocus && !s:last_autofocus - let curfile = s:known_files.getCurrent(1) + let curfile = s:state.getCurrent(1) if !empty(curfile) && curfile.fpath != fnamemodify(bufname('%'), ':p') let winnr = bufwinnr(curfile.fpath) if winnr != -1 @@ -2633,7 +2637,7 @@ endfunction " s:ToggleSort() {{{2 function! s:ToggleSort() abort - let fileinfo = s:known_files.getCurrent(0) + let fileinfo = s:state.getCurrent(0) if empty(fileinfo) return endif @@ -2675,7 +2679,7 @@ function! s:RenderContent(...) abort if a:0 == 1 let fileinfo = a:1 else - let fileinfo = s:known_files.getCurrent(0) + let fileinfo = s:state.getCurrent(0) endif if empty(fileinfo) @@ -2700,8 +2704,8 @@ function! s:RenderContent(...) abort call s:goto_win(tagbarwinnr, 1) endif - if !empty(s:known_files.getCurrent(0)) && - \ fileinfo.fpath ==# s:known_files.getCurrent(0).fpath + if !empty(s:state.getCurrent(0)) && + \ fileinfo.fpath ==# s:state.getCurrent(0).fpath " We're redisplaying the same file, so save the view call s:debug('Redisplaying file [' . fileinfo.fpath . ']') let saveline = line('.') @@ -2745,8 +2749,8 @@ function! s:RenderContent(...) abort setlocal nomodifiable - if !empty(s:known_files.getCurrent(0)) && - \ fileinfo.fpath ==# s:known_files.getCurrent(0).fpath + if !empty(s:state.getCurrent(0)) && + \ fileinfo.fpath ==# s:state.getCurrent(0).fpath let scrolloff_save = &scrolloff set scrolloff=0 @@ -3246,7 +3250,7 @@ endfunction " Folding {{{1 " s:OpenFold() {{{2 function! s:OpenFold() abort - let fileinfo = s:known_files.getCurrent(0) + let fileinfo = s:state.getCurrent(0) if empty(fileinfo) return endif @@ -3265,7 +3269,7 @@ endfunction " s:CloseFold() {{{2 function! s:CloseFold() abort - let fileinfo = s:known_files.getCurrent(0) + let fileinfo = s:state.getCurrent(0) if empty(fileinfo) return endif @@ -3286,7 +3290,7 @@ endfunction " s:ToggleFold() {{{2 function! s:ToggleFold() abort - let fileinfo = s:known_files.getCurrent(0) + let fileinfo = s:state.getCurrent(0) if empty(fileinfo) return endif @@ -3322,7 +3326,7 @@ function! s:SetFoldLevel(level, force) abort return endif - let fileinfo = s:known_files.getCurrent(0) + let fileinfo = s:state.getCurrent(0) if empty(fileinfo) return endif @@ -3518,8 +3522,8 @@ function! s:AutoUpdate(fname, force) abort " file is being displayed if bufwinnr('__Tagbar__') != -1 && !s:paused && \ (s:new_window || updated || - \ (!empty(s:known_files.getCurrent(0)) && - \ a:fname != s:known_files.getCurrent(0).fpath)) + \ (!empty(s:state.getCurrent(0)) && + \ a:fname != s:state.getCurrent(0).fpath)) call s:RenderContent(fileinfo) endif @@ -3527,7 +3531,7 @@ function! s:AutoUpdate(fname, force) abort " same file is being redisplayed if !empty(fileinfo) call s:debug('Setting current file [' . a:fname . ']') - call s:known_files.setCurrent(fileinfo) + call s:state.setCurrent(fileinfo) let s:nearby_disabled = 0 endif @@ -3743,7 +3747,7 @@ function! s:GetNearbyTag(all, forcecurrent, ...) abort return {} endif - let fileinfo = s:known_files.getCurrent(a:forcecurrent) + let fileinfo = s:state.getCurrent(a:forcecurrent) if empty(fileinfo) return {} endif @@ -3779,7 +3783,7 @@ endfunction " does not contain a valid tag (for example because it is empty or only " contains a pseudo-tag) return an empty dictionary. function! s:GetTagInfo(linenr, ignorepseudo) abort - let fileinfo = s:known_files.getCurrent(0) + let fileinfo = s:state.getCurrent(0) if empty(fileinfo) return {} @@ -3865,7 +3869,7 @@ endfunction " s:ToggleHideNonPublicTags() {{{2 function! s:ToggleHideNonPublicTags() abort - let fileinfo = s:known_files.getCurrent(0) + let fileinfo = s:state.getCurrent(0) if empty(fileinfo) return endif @@ -3891,7 +3895,7 @@ endfunction " s:ToggleCaseInsensitive() {{{2 function! s:ToggleCaseInsensitive() abort - let fileinfo = s:known_files.getCurrent(0) + let fileinfo = s:state.getCurrent(0) if empty(fileinfo) return endif @@ -3978,8 +3982,8 @@ function! s:SetStatusLine() let sort = g:tagbar_sort ? 'Name' : 'Order' - if !empty(s:known_files.getCurrent(0)) - let fname = fnamemodify(s:known_files.getCurrent(0).fpath, ':t') + if !empty(s:state.getCurrent(0)) + let fname = fnamemodify(s:state.getCurrent(0).fpath, ':t') else let fname = '' endif @@ -4236,7 +4240,7 @@ function! tagbar#toggle_pause() abort let s:paused = !s:paused if s:paused - call s:known_files.setPaused() + call s:state.setPaused() else call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 1) endif @@ -4317,8 +4321,8 @@ endfunction function! tagbar#currentfile() abort let filename = '' - if !empty(s:known_files.getCurrent(1)) - let filename = fnamemodify(s:known_files.getCurrent(1).fpath, ':t') + if !empty(s:state.getCurrent(1)) + let filename = fnamemodify(s:state.getCurrent(1).fpath, ':t') endif return filename From 7c5606668526c999c9a5c72ff1ec23300ae2a60f Mon Sep 17 00:00:00 2001 From: Martin Vuille Date: Sat, 24 Sep 2016 17:48:52 -0400 Subject: [PATCH 2/5] Give each tab its own tagbar buffer --- autoload/tagbar.vim | 53 +++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index e8a5e74..06aab50 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -65,6 +65,8 @@ let s:short_help = 1 let s:nearby_disabled = 0 let s:paused = 0 let s:pwin_by_tagbar = 0 +let s:vim_quitting = 0 +let s:buffer_seqno = 0 let s:window_expanded = 0 let s:expand_bufnr = -1 @@ -943,7 +945,7 @@ function! s:RestoreSession() abort let curfile = fnamemodify(bufname('%'), ':p') - let tagbarwinnr = bufwinnr('__Tagbar__') + let tagbarwinnr = bufwinnr(s:TagbarBufName()) if tagbarwinnr == -1 " Tagbar wasn't open in the saved session, nothing to do return @@ -1030,16 +1032,16 @@ function! s:CreateAutocommands() abort augroup TagbarAutoCmds autocmd! - autocmd CursorHold __Tagbar__ call s:ShowPrototype(1) - autocmd WinEnter __Tagbar__ call s:SetStatusLine() - autocmd WinLeave __Tagbar__ call s:SetStatusLine() + autocmd CursorHold __Tagbar__.* call s:ShowPrototype(1) + autocmd WinEnter __Tagbar__.* call s:SetStatusLine() + autocmd WinLeave __Tagbar__.* call s:SetStatusLine() if g:tagbar_autopreview - autocmd CursorMoved __Tagbar__ nested call s:ShowInPreviewWin() + autocmd CursorMoved __Tagbar__.* nested call s:ShowInPreviewWin() endif autocmd WinEnter * nested call s:QuitIfOnlyWindow() - autocmd WinEnter * if bufwinnr('__Tagbar__') == -1 | + autocmd WinEnter * if bufwinnr(s:TagbarBufName()) == -1 | \ call s:ShrinkIfExpanded() | \ endif @@ -1766,7 +1768,7 @@ endfunction function! s:ToggleWindow() abort call s:debug('ToggleWindow called') - let tagbarwinnr = bufwinnr("__Tagbar__") + let tagbarwinnr = bufwinnr(s:TagbarBufName()) if tagbarwinnr != -1 call s:CloseWindow() return @@ -1790,7 +1792,7 @@ function! s:OpenWindow(flags) abort " If the tagbar window is already open check jump flag " Also set the autoclose flag if requested - let tagbarwinnr = bufwinnr('__Tagbar__') + let tagbarwinnr = bufwinnr(s:TagbarBufName()) if tagbarwinnr != -1 if winnr() != tagbarwinnr && jump call s:goto_win(tagbarwinnr) @@ -1827,7 +1829,7 @@ function! s:OpenWindow(flags) abort let openpos = g:tagbar_left ? 'leftabove ' : 'rightbelow ' let width = g:tagbar_vertical endif - exe 'silent keepalt ' . openpos . width . 'split ' . '__Tagbar__' + exe 'silent keepalt ' . openpos . width . 'split ' . s:TagbarBufName() unlet s:window_opening call s:InitWindow(autoclose) @@ -1923,7 +1925,7 @@ endfunction function! s:CloseWindow() abort call s:debug('CloseWindow called') - let tagbarwinnr = bufwinnr('__Tagbar__') + let tagbarwinnr = bufwinnr(s:TagbarBufName()) if tagbarwinnr == -1 return endif @@ -1931,7 +1933,7 @@ function! s:CloseWindow() abort " Close the preview window if it was opened by us if s:pwin_by_tagbar pclose - let tagbarwinnr = bufwinnr('__Tagbar__') + let tagbarwinnr = bufwinnr(s:TagbarBufName()) endif if winnr() == tagbarwinnr @@ -2039,7 +2041,7 @@ endfunction " g:tagbar_left is set. This should work around it by jumping to the window of " the current file after startup. function! s:CorrectFocusOnStartup() abort - if bufwinnr('__Tagbar__') != -1 && !g:tagbar_autofocus && !s:last_autofocus + if bufwinnr(s:TagbarBufName()) != -1 && !g:tagbar_autofocus && !s:last_autofocus let curfile = s:state.getCurrent(1) if !empty(curfile) && curfile.fpath != fnamemodify(bufname('%'), ':p') let winnr = bufwinnr(curfile.fpath) @@ -2263,7 +2265,7 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort call s:debug(ctags_output) " Only display an error message if the Tagbar window is open and we " haven't seen the error before. - if bufwinnr("__Tagbar__") != -1 && + if bufwinnr(s:TagbarBufName()) != -1 && \ (!s:known_files.has(a:realfname) || \ !empty(s:known_files.get(a:realfname))) call s:warning('Tagbar: Could not execute ctags for ' . a:realfname . '!') @@ -2687,7 +2689,7 @@ function! s:RenderContent(...) abort return endif - let tagbarwinnr = bufwinnr('__Tagbar__') + let tagbarwinnr = bufwinnr(s:TagbarBufName()) if &filetype == 'tagbar' let in_tagbar = 1 @@ -3001,7 +3003,7 @@ function! s:HighlightTag(openfolds, ...) abort let s:last_highlight_tline = tagline endif - let tagbarwinnr = bufwinnr('__Tagbar__') + let tagbarwinnr = bufwinnr(s:TagbarBufName()) if tagbarwinnr == -1 return endif @@ -3520,7 +3522,7 @@ function! s:AutoUpdate(fname, force) abort " Display the tagbar content if the tags have been updated or a different " file is being displayed - if bufwinnr('__Tagbar__') != -1 && !s:paused && + if bufwinnr(s:TagbarBufName()) != -1 && !s:paused && \ (s:new_window || updated || \ (!empty(s:state.getCurrent(0)) && \ a:fname != s:state.getCurrent(0).fpath)) @@ -3790,7 +3792,7 @@ function! s:GetTagInfo(linenr, ignorepseudo) abort endif " Don't do anything in empty and comment lines - let curline = getbufline(bufnr('__Tagbar__'), a:linenr)[0] + let curline = getbufline(bufnr(s:TagbarBufName()), a:linenr)[0] if curline =~ '^\s*$' || curline[0] == '"' return {} endif @@ -3969,7 +3971,7 @@ endfunction " s:SetStatusLine() {{{2 function! s:SetStatusLine() " Make sure we're actually in the Tagbar window - let tagbarwinnr = bufwinnr('__Tagbar__') + let tagbarwinnr = bufwinnr(s:TagbarBufName()) if tagbarwinnr == -1 return endif @@ -4014,7 +4016,7 @@ endfunction " s:QuitIfOnlyWindow() {{{2 function! s:QuitIfOnlyWindow() abort - let tagbarwinnr = bufwinnr('__Tagbar__') + let tagbarwinnr = bufwinnr(s:TagbarBufName()) if tagbarwinnr == -1 return endif @@ -4082,6 +4084,15 @@ function! s:NextNormalWindow() abort return -1 endfunction +function! s:TagbarBufName() abort + if !exists('t:tagbar_buf_name') + let s:buffer_seqno += 1 + let t:tagbar_buf_name = '__Tagbar__.' . s:buffer_seqno + endif + + return t:tagbar_buf_name +endfunction + " s:goto_win() {{{2 function! s:goto_win(winnr, ...) abort let cmd = type(a:winnr) == type(0) ? a:winnr . 'wincmd w' @@ -4100,7 +4111,7 @@ endfunction " s:goto_tagbar() {{{2 function! s:goto_tagbar(...) abort let noauto = a:0 > 0 ? a:1 : 0 - call s:goto_win(bufwinnr('__Tagbar__'), noauto) + call s:goto_win(bufwinnr(s:TagbarBufName()), noauto) endfunction " s:mark_window() {{{2 @@ -4210,7 +4221,7 @@ function! tagbar#SetFoldLevel(level, force) abort endfunction function! tagbar#highlighttag(openfolds, force) abort - let tagbarwinnr = bufwinnr('__Tagbar__') + let tagbarwinnr = bufwinnr(s:TagbarBufName()) if tagbarwinnr == -1 echohl WarningMsg echomsg "Warning: Can't highlight tag, Tagbar window not open" From 1e5b704e09adb903896888a6e9a1d8db08bc9869 Mon Sep 17 00:00:00 2001 From: Martin Vuille Date: Sat, 24 Sep 2016 17:49:35 -0400 Subject: [PATCH 3/5] Give each tab its own tagbar instance data --- autoload/tagbar.vim | 67 +++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index 06aab50..fbd76df 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -1574,7 +1574,7 @@ endfunction " s:KindheaderTag.toggleFold() {{{3 function! s:KindheaderTag.toggleFold() abort dict - let fileinfo = s:state.getCurrent(0) + let fileinfo = s:TagbarState().getCurrent(0) let fileinfo.kindfolds[self.short] = !fileinfo.kindfolds[self.short] endfunction @@ -1704,12 +1704,17 @@ function! s:FileInfo.closeKindFold(kind) abort dict let self.kindfolds[a:kind.short] = 1 endfunction -" Per-tagbar instance state {{{2 +" Per-tagbar instance state prototype {{{2 let s:state = { \ '_current' : {}, \ '_paused' : {}, \ } +" s:state.New() {{{3 +function! s:state.New() abort dict + return deepcopy(self) +endfunction + " s:state.getCurrent() {{{3 function! s:state.getCurrent(forcecurrent) abort dict if !s:paused || a:forcecurrent @@ -1940,7 +1945,7 @@ function! s:CloseWindow() abort if winbufnr(2) != -1 " Other windows are open, only close the tagbar one - let curfile = s:state.getCurrent(0) + let curfile = s:TagbarState().getCurrent(0) close @@ -2042,7 +2047,7 @@ endfunction " the current file after startup. function! s:CorrectFocusOnStartup() abort if bufwinnr(s:TagbarBufName()) != -1 && !g:tagbar_autofocus && !s:last_autofocus - let curfile = s:state.getCurrent(1) + let curfile = s:TagbarState().getCurrent(1) if !empty(curfile) && curfile.fpath != fnamemodify(bufname('%'), ':p') let winnr = bufwinnr(curfile.fpath) if winnr != -1 @@ -2639,7 +2644,7 @@ endfunction " s:ToggleSort() {{{2 function! s:ToggleSort() abort - let fileinfo = s:state.getCurrent(0) + let fileinfo = s:TagbarState().getCurrent(0) if empty(fileinfo) return endif @@ -2681,7 +2686,7 @@ function! s:RenderContent(...) abort if a:0 == 1 let fileinfo = a:1 else - let fileinfo = s:state.getCurrent(0) + let fileinfo = s:TagbarState().getCurrent(0) endif if empty(fileinfo) @@ -2706,8 +2711,8 @@ function! s:RenderContent(...) abort call s:goto_win(tagbarwinnr, 1) endif - if !empty(s:state.getCurrent(0)) && - \ fileinfo.fpath ==# s:state.getCurrent(0).fpath + if !empty(s:TagbarState().getCurrent(0)) && + \ fileinfo.fpath ==# s:TagbarState().getCurrent(0).fpath " We're redisplaying the same file, so save the view call s:debug('Redisplaying file [' . fileinfo.fpath . ']') let saveline = line('.') @@ -2751,8 +2756,8 @@ function! s:RenderContent(...) abort setlocal nomodifiable - if !empty(s:state.getCurrent(0)) && - \ fileinfo.fpath ==# s:state.getCurrent(0).fpath + if !empty(s:TagbarState().getCurrent(0)) && + \ fileinfo.fpath ==# s:TagbarState().getCurrent(0).fpath let scrolloff_save = &scrolloff set scrolloff=0 @@ -3252,7 +3257,7 @@ endfunction " Folding {{{1 " s:OpenFold() {{{2 function! s:OpenFold() abort - let fileinfo = s:state.getCurrent(0) + let fileinfo = s:TagbarState().getCurrent(0) if empty(fileinfo) return endif @@ -3271,7 +3276,7 @@ endfunction " s:CloseFold() {{{2 function! s:CloseFold() abort - let fileinfo = s:state.getCurrent(0) + let fileinfo = s:TagbarState().getCurrent(0) if empty(fileinfo) return endif @@ -3292,7 +3297,7 @@ endfunction " s:ToggleFold() {{{2 function! s:ToggleFold() abort - let fileinfo = s:state.getCurrent(0) + let fileinfo = s:TagbarState().getCurrent(0) if empty(fileinfo) return endif @@ -3328,7 +3333,7 @@ function! s:SetFoldLevel(level, force) abort return endif - let fileinfo = s:state.getCurrent(0) + let fileinfo = s:TagbarState().getCurrent(0) if empty(fileinfo) return endif @@ -3524,8 +3529,8 @@ function! s:AutoUpdate(fname, force) abort " file is being displayed if bufwinnr(s:TagbarBufName()) != -1 && !s:paused && \ (s:new_window || updated || - \ (!empty(s:state.getCurrent(0)) && - \ a:fname != s:state.getCurrent(0).fpath)) + \ (!empty(s:TagbarState().getCurrent(0)) && + \ a:fname != s:TagbarState().getCurrent(0).fpath)) call s:RenderContent(fileinfo) endif @@ -3533,7 +3538,7 @@ function! s:AutoUpdate(fname, force) abort " same file is being redisplayed if !empty(fileinfo) call s:debug('Setting current file [' . a:fname . ']') - call s:state.setCurrent(fileinfo) + call s:TagbarState().setCurrent(fileinfo) let s:nearby_disabled = 0 endif @@ -3749,7 +3754,7 @@ function! s:GetNearbyTag(all, forcecurrent, ...) abort return {} endif - let fileinfo = s:state.getCurrent(a:forcecurrent) + let fileinfo = s:TagbarState().getCurrent(a:forcecurrent) if empty(fileinfo) return {} endif @@ -3785,7 +3790,7 @@ endfunction " does not contain a valid tag (for example because it is empty or only " contains a pseudo-tag) return an empty dictionary. function! s:GetTagInfo(linenr, ignorepseudo) abort - let fileinfo = s:state.getCurrent(0) + let fileinfo = s:TagbarState().getCurrent(0) if empty(fileinfo) return {} @@ -3871,7 +3876,7 @@ endfunction " s:ToggleHideNonPublicTags() {{{2 function! s:ToggleHideNonPublicTags() abort - let fileinfo = s:state.getCurrent(0) + let fileinfo = s:TagbarState().getCurrent(0) if empty(fileinfo) return endif @@ -3897,7 +3902,7 @@ endfunction " s:ToggleCaseInsensitive() {{{2 function! s:ToggleCaseInsensitive() abort - let fileinfo = s:state.getCurrent(0) + let fileinfo = s:TagbarState().getCurrent(0) if empty(fileinfo) return endif @@ -3984,8 +3989,8 @@ function! s:SetStatusLine() let sort = g:tagbar_sort ? 'Name' : 'Order' - if !empty(s:state.getCurrent(0)) - let fname = fnamemodify(s:state.getCurrent(0).fpath, ':t') + if !empty(s:TagbarState().getCurrent(0)) + let fname = fnamemodify(s:TagbarState().getCurrent(0).fpath, ':t') else let fname = '' endif @@ -4084,6 +4089,7 @@ function! s:NextNormalWindow() abort return -1 endfunction +" s:TagbarBufName() {{{2 function! s:TagbarBufName() abort if !exists('t:tagbar_buf_name') let s:buffer_seqno += 1 @@ -4093,6 +4099,15 @@ function! s:TagbarBufName() abort return t:tagbar_buf_name endfunction +" s:TagbarState() {{{2 +function! s:TagbarState() abort + if !exists('t:tagbar_state') + let t:tagbar_state = s:state.New() + endif + + return t:tagbar_state +endfunction + " s:goto_win() {{{2 function! s:goto_win(winnr, ...) abort let cmd = type(a:winnr) == type(0) ? a:winnr . 'wincmd w' @@ -4251,7 +4266,7 @@ function! tagbar#toggle_pause() abort let s:paused = !s:paused if s:paused - call s:state.setPaused() + call s:TagbarState().setPaused() else call s:AutoUpdate(fnamemodify(expand('%'), ':p'), 1) endif @@ -4332,8 +4347,8 @@ endfunction function! tagbar#currentfile() abort let filename = '' - if !empty(s:state.getCurrent(1)) - let filename = fnamemodify(s:state.getCurrent(1).fpath, ':t') + if !empty(s:TagbarState().getCurrent(1)) + let filename = fnamemodify(s:TagbarState().getCurrent(1).fpath, ':t') endif return filename From b1e1063b373f9b19c100500702575eb343e466a6 Mon Sep 17 00:00:00 2001 From: Martin Vuille Date: Sat, 24 Sep 2016 18:40:44 -0400 Subject: [PATCH 4/5] Clean-up for pull request --- autoload/tagbar.vim | 1 - 1 file changed, 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index fbd76df..de9108c 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -65,7 +65,6 @@ let s:short_help = 1 let s:nearby_disabled = 0 let s:paused = 0 let s:pwin_by_tagbar = 0 -let s:vim_quitting = 0 let s:buffer_seqno = 0 let s:window_expanded = 0 From 321fdd4fd1ea9e5a1dedb4a17f1f36c1d636b473 Mon Sep 17 00:00:00 2001 From: Martin Vuille Date: Wed, 28 Sep 2016 06:20:25 -0400 Subject: [PATCH 5/5] Don't close new tab --- autoload/tagbar.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index de9108c..6241eab 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -4041,7 +4041,7 @@ function! s:QuitIfOnlyWindow() abort noautocmd bdelete endif quit - else + elseif exists('t:tagbar_buf_name') close endif endif