From 18b536ce43f1be88be380e5f3b7cd0fd930b4908 Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Tue, 3 Jan 2017 15:21:10 +1300 Subject: [PATCH] Save last alt bufnr before switching buffers, closes #385 When switching buffers during the handling of the BufDelete event the saved buffer number of the last alternate buffer will change, so we have to save a local copy to be able to properly unset the 'tagbar_ignore' buffer variable. --- autoload/tagbar.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/autoload/tagbar.vim b/autoload/tagbar.vim index d75d330..0cc05a5 100644 --- a/autoload/tagbar.vim +++ b/autoload/tagbar.vim @@ -4193,11 +4193,15 @@ function! s:HandleBufDelete(bufname, bufnr) abort enew endif else + " Save a local copy as the global value will change + " during buffer switching + let last_alt_bufnr = s:last_alt_bufnr + " Ignore the buffer we're switching to for now, it will get " processed due to the OpenWindow() call anyway - call setbufvar(s:last_alt_bufnr, 'tagbar_ignore', 1) - execute 'keepalt buffer' s:last_alt_bufnr - call setbufvar(s:last_alt_bufnr, 'tagbar_ignore', 0) + call setbufvar(last_alt_bufnr, 'tagbar_ignore', 1) + execute 'keepalt buffer' last_alt_bufnr + call setbufvar(last_alt_bufnr, 'tagbar_ignore', 0) endif " Reset Tagbar window-local options