Merge pull request #801 from mrubli/focus-on-close
Fix focussing previous buffer when closing NERDTree
This commit is contained in:
commit
e47e588705
@ -38,17 +38,26 @@ function! s:NERDTree.Close()
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if winnr("$") != 1
|
if winnr("$") != 1
|
||||||
|
" Use the window ID to identify the currently active window or fall
|
||||||
|
" back on the buffer ID if win_getid/win_gotoid are not available, in
|
||||||
|
" which case we'll focus an arbitrary window showing the buffer.
|
||||||
|
let l:useWinId = exists('*win_getid') && exists('*win_gotoid')
|
||||||
|
|
||||||
if winnr() == s:NERDTree.GetWinNum()
|
if winnr() == s:NERDTree.GetWinNum()
|
||||||
call nerdtree#exec("wincmd p")
|
call nerdtree#exec("wincmd p")
|
||||||
let bufnr = bufnr("")
|
let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("")
|
||||||
call nerdtree#exec("wincmd p")
|
call nerdtree#exec("wincmd p")
|
||||||
else
|
else
|
||||||
let bufnr = bufnr("")
|
let l:activeBufOrWin = l:useWinId ? win_getid() : bufnr("")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w")
|
call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w")
|
||||||
close
|
close
|
||||||
call nerdtree#exec(bufwinnr(bufnr) . " wincmd w")
|
if l:useWinId
|
||||||
|
call nerdtree#exec("call win_gotoid(" . l:activeBufOrWin . ")")
|
||||||
|
else
|
||||||
|
call nerdtree#exec(bufwinnr(l:activeBufOrWin) . " wincmd w")
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
close
|
close
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user