From b1b7667a1f2e52f61eab21ef86622dcf412ba431 Mon Sep 17 00:00:00 2001 From: Bill Ming Date: Thu, 23 Aug 2018 11:38:36 -0700 Subject: [PATCH] autochdir will sometimes change the bufname('%') results and making it harder to tell if the buffer is belong to undotree. Switching to a buf variable would be much reliable. --- autoload/undotree.vim | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/autoload/undotree.vim b/autoload/undotree.vim index cd31dac..7b89323 100644 --- a/autoload/undotree.vim +++ b/autoload/undotree.vim @@ -168,7 +168,7 @@ function! s:getUniqueID() return s:cntr endfunction -" Debug... +" Set to 1 to enable debug log let s:debug = 0 let s:debugfile = $HOME.'/undotree_debug.log' " If debug file exists, enable debug output. @@ -307,12 +307,12 @@ endfunction function! s:undotree.Action(action) call s:log("undotree.Action() ".a:action) - if !self.IsVisible() || bufname("%") != self.bufname - echoerr "Fatal: window does not exists." + if !self.IsVisible() || !exists('b:isUndotreeBuffer') + echoerr "Fatal: window does not exist." return endif if !has_key(self,'Action'.a:action) - echoerr "Fatal: Action does not exists!" + echoerr "Fatal: Action does not exist!" return endif silent exec 'call self.Action'.a:action.'()' @@ -499,6 +499,11 @@ function! s:undotree.Show() endif call s:exec("silent keepalt ".cmd) call self.SetFocus() + + " We need a way to tell if the buffer is belong to undotree, + " bufname() is not always reliable. + let b:isUndotreeBuffer = 1 + setlocal winfixwidth setlocal noswapfile setlocal buftype=nowrite @@ -538,8 +543,7 @@ function! s:undotree.Update() return endif " do nothing if we're in the undotree or diff panel - let bufname = bufname('%') - if bufname == self.bufname || bufname == t:diffpanel.bufname + if exists('b:isUndotreeBuffer') return endif if (&bt != '' && &bt != 'acwrite') || (&modifiable == 0) || (mode() != 'n') @@ -1172,6 +1176,8 @@ function! s:diffpanel.Show() endif call s:exec_silent(cmd) + let b:isUndotreeBuffer = 1 + setlocal winfixwidth setlocal winfixheight setlocal noswapfile