move the closeTree functions out of autoload

Remove `closeTreeIfOpen` and just make `closeTree` fail silently.
This commit is contained in:
Martin Grenfell 2015-05-02 15:01:58 +01:00
parent 0d88ce946f
commit 53d2de86eb
5 changed files with 38 additions and 45 deletions

View File

@ -98,44 +98,6 @@ endfunction
" SECTION: View Functions {{{1
"============================================================
"FUNCTION: nerdtree#closeTree() {{{2
"Closes the primary NERD tree window for this tab
function! nerdtree#closeTree()
call g:NERDTree.MustBeOpen()
if winnr("$") != 1
if winnr() == g:NERDTree.GetWinNum()
call nerdtree#exec("wincmd p")
let bufnr = bufnr("")
call nerdtree#exec("wincmd p")
else
let bufnr = bufnr("")
endif
call nerdtree#exec(g:NERDTree.GetWinNum() . " wincmd w")
close
call nerdtree#exec(bufwinnr(bufnr) . " wincmd w")
else
close
endif
endfunction
"FUNCTION: nerdtree#closeTreeIfOpen() {{{2
"Closes the NERD tree window if it is open
function! nerdtree#closeTreeIfOpen()
if g:NERDTree.IsOpen()
call nerdtree#closeTree()
endif
endfunction
"FUNCTION: nerdtree#closeTreeIfQuitOnOpen() {{{2
"Closes the NERD tree window if the close on open option is set
function! nerdtree#closeTreeIfQuitOnOpen()
if g:NERDTreeQuitOnOpen && g:NERDTree.IsOpen()
call nerdtree#closeTree()
endif
endfunction
"FUNCTION: nerdtree#dumpHelp {{{2
"prints out the quick help
function! nerdtree#dumpHelp()

View File

@ -212,7 +212,7 @@ function! s:closeTreeWindow()
exec "buffer " . b:NERDTreePreviousBuf
else
if winnr("$") > 1
call nerdtree#closeTree()
call g:NERDTree.Close()
else
call nerdtree#echo("Cannot close last window")
endif
@ -547,7 +547,7 @@ endfunction
function! nerdtree#ui_glue#setupCommands()
command! -n=? -complete=dir -bar NERDTree :call g:NERDTreeCreator.CreatePrimary('<args>')
command! -n=? -complete=dir -bar NERDTreeToggle :call g:NERDTreeCreator.TogglePrimary('<args>')
command! -n=0 -bar NERDTreeClose :call nerdtree#closeTreeIfOpen()
command! -n=0 -bar NERDTreeClose :call g:NERDTree.Close()
command! -n=1 -complete=customlist,nerdtree#completeBookmarks -bar NERDTreeFromBookmark call g:NERDTreeCreator.CreatePrimary('<args>')
command! -n=0 -bar NERDTreeMirror call g:NERDTreeCreator.CreateMirror()
command! -n=0 -bar NERDTreeFind call s:findAndRevealPath()

View File

@ -56,7 +56,7 @@ function! s:Creator.createPrimary(name)
if g:NERDTree.ExistsForTab()
if g:NERDTree.IsOpen()
call nerdtree#closeTree()
call g:NERDTree.Close()
endif
unlet t:NERDTreeBufName
endif
@ -169,7 +169,7 @@ function! s:Creator.createMirror()
endif
if g:NERDTree.ExistsForTab() && g:NERDTree.IsOpen()
call nerdtree#closeTree()
call g:NERDTree.Close()
endif
let t:NERDTreeBufName = bufferName
@ -340,7 +340,7 @@ function! s:Creator.togglePrimary(dir)
endif
call b:NERDTree.ui.restoreScreenState()
else
call nerdtree#closeTree()
call g:NERDTree.Close()
endif
else
call self.createPrimary(a:dir)

View File

@ -3,6 +3,38 @@
let s:NERDTree = {}
let g:NERDTree = s:NERDTree
"FUNCTION: s:NERDTree.Close() {{{1
"Closes the primary NERD tree window for this tab
function! s:NERDTree.Close()
if !s:NERDTree.IsOpen()
return
endif
if winnr("$") != 1
if winnr() == s:NERDTree.GetWinNum()
call nerdtree#exec("wincmd p")
let bufnr = bufnr("")
call nerdtree#exec("wincmd p")
else
let bufnr = bufnr("")
endif
call nerdtree#exec(s:NERDTree.GetWinNum() . " wincmd w")
close
call nerdtree#exec(bufwinnr(bufnr) . " wincmd w")
else
close
endif
endfunction
"FUNCTION: s:NERDTree.CloseIfQuitOnOpen() {{{1
"Closes the NERD tree window if the close on open option is set
function! s:NERDTree.CloseIfQuitOnOpen()
if g:NERDTreeQuitOnOpen && s:NERDTree.IsOpen()
call s:NERDTree.Close()
endif
endfunction
" Function: s:NERDTree.ExistsForBuffer() {{{1
" Returns 1 if a nerd tree root exists in the current buffer
function! s:NERDTree.ExistsForBuf()
@ -59,4 +91,3 @@ endfunction
function! s:NERDTree.render()
call self.ui.render()
endfunction

View File

@ -40,7 +40,7 @@ function! s:Opener._checkToCloseTree(newtab)
endif
if (a:newtab && self._where == 't') || !a:newtab
call nerdtree#closeTreeIfQuitOnOpen()
call g:NERDTree.CloseIfQuitOnOpen()
endif
endfunction