Skip to content

Commit

Permalink
autochdir will sometimes change the bufname('%') results and making i…
Browse files Browse the repository at this point in the history
…t harder to tell if the buffer is belong to undotree. Switching to a buf variable would be much reliable.
  • Loading branch information
mbbill committed Aug 23, 2018
1 parent a80159c commit b1b7667
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions autoload/undotree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.'()'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -1172,6 +1176,8 @@ function! s:diffpanel.Show()
endif
call s:exec_silent(cmd)

let b:isUndotreeBuffer = 1

setlocal winfixwidth
setlocal winfixheight
setlocal noswapfile
Expand Down

0 comments on commit b1b7667

Please sign in to comment.