mirror of
https://github.com/preservim/nerdtree.git
synced 2024-11-22 13:12:40 +08:00
move isTreeOpen() out of autoload
This commit is contained in:
parent
8270b6d717
commit
0d88ce946f
|
@ -101,9 +101,7 @@ endfunction
|
|||
"FUNCTION: nerdtree#closeTree() {{{2
|
||||
"Closes the primary NERD tree window for this tab
|
||||
function! nerdtree#closeTree()
|
||||
if !nerdtree#isTreeOpen()
|
||||
throw "NERDTree.NoTreeFoundError: no NERDTree is open"
|
||||
endif
|
||||
call g:NERDTree.MustBeOpen()
|
||||
|
||||
if winnr("$") != 1
|
||||
if winnr() == g:NERDTree.GetWinNum()
|
||||
|
@ -125,7 +123,7 @@ endfunction
|
|||
"FUNCTION: nerdtree#closeTreeIfOpen() {{{2
|
||||
"Closes the NERD tree window if it is open
|
||||
function! nerdtree#closeTreeIfOpen()
|
||||
if nerdtree#isTreeOpen()
|
||||
if g:NERDTree.IsOpen()
|
||||
call nerdtree#closeTree()
|
||||
endif
|
||||
endfunction
|
||||
|
@ -133,7 +131,7 @@ endfunction
|
|||
"FUNCTION: nerdtree#closeTreeIfQuitOnOpen() {{{2
|
||||
"Closes the NERD tree window if the close on open option is set
|
||||
function! nerdtree#closeTreeIfQuitOnOpen()
|
||||
if g:NERDTreeQuitOnOpen && nerdtree#isTreeOpen()
|
||||
if g:NERDTreeQuitOnOpen && g:NERDTree.IsOpen()
|
||||
call nerdtree#closeTree()
|
||||
endif
|
||||
endfunction
|
||||
|
@ -275,11 +273,6 @@ function! nerdtree#echoWarning(msg)
|
|||
echohl normal
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#isTreeOpen() {{{2
|
||||
function! nerdtree#isTreeOpen()
|
||||
return g:NERDTree.GetWinNum() != -1
|
||||
endfunction
|
||||
|
||||
"FUNCTION: nerdtree#putCursorOnBookmarkTable(){{{2
|
||||
"Places the cursor at the top of the bookmarks table
|
||||
function! nerdtree#putCursorOnBookmarkTable()
|
||||
|
@ -306,10 +299,7 @@ endfunction
|
|||
"FUNCTION: nerdtree#putCursorInTreeWin(){{{2
|
||||
"Places the cursor in the nerd tree window
|
||||
function! nerdtree#putCursorInTreeWin()
|
||||
if !nerdtree#isTreeOpen()
|
||||
throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists"
|
||||
endif
|
||||
|
||||
call g:NERDTree.MustBeOpen()
|
||||
call nerdtree#exec(g:NERDTree.GetWinNum() . "wincmd w")
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ function! s:findAndRevealPath()
|
|||
endif
|
||||
else
|
||||
if !p.isUnder(g:NERDTreeFileNode.GetRootForTab().path)
|
||||
if !nerdtree#isTreeOpen()
|
||||
if !g:NERDTree.IsOpen()
|
||||
call g:NERDTreeCreator.TogglePrimary('')
|
||||
else
|
||||
call nerdtree#putCursorInTreeWin()
|
||||
|
@ -283,7 +283,7 @@ function! s:findAndRevealPath()
|
|||
let b:NERDTreeShowHidden = g:NERDTreeShowHidden
|
||||
call s:chRoot(g:NERDTreeDirNode.New(p.getParent()))
|
||||
else
|
||||
if !nerdtree#isTreeOpen()
|
||||
if !g:NERDTree.IsOpen()
|
||||
call g:NERDTreeCreator.TogglePrimary("")
|
||||
endif
|
||||
endif
|
||||
|
|
|
@ -55,7 +55,7 @@ function! s:Creator.createPrimary(name)
|
|||
endif
|
||||
|
||||
if g:NERDTree.ExistsForTab()
|
||||
if nerdtree#isTreeOpen()
|
||||
if g:NERDTree.IsOpen()
|
||||
call nerdtree#closeTree()
|
||||
endif
|
||||
unlet t:NERDTreeBufName
|
||||
|
@ -168,7 +168,7 @@ function! s:Creator.createMirror()
|
|||
return
|
||||
endif
|
||||
|
||||
if g:NERDTree.ExistsForTab() && nerdtree#isTreeOpen()
|
||||
if g:NERDTree.ExistsForTab() && g:NERDTree.IsOpen()
|
||||
call nerdtree#closeTree()
|
||||
endif
|
||||
|
||||
|
@ -333,7 +333,7 @@ endfunction
|
|||
"initialized.
|
||||
function! s:Creator.togglePrimary(dir)
|
||||
if g:NERDTree.ExistsForTab()
|
||||
if !nerdtree#isTreeOpen()
|
||||
if !g:NERDTree.IsOpen()
|
||||
call self._createTreeWin()
|
||||
if !&hidden
|
||||
call b:NERDTree.render()
|
||||
|
|
|
@ -33,6 +33,19 @@ function! s:NERDTree.GetWinNum()
|
|||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.IsOpen() {{{1
|
||||
function! s:NERDTree.IsOpen()
|
||||
return s:NERDTree.GetWinNum() != -1
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.MustBeOpen() {{{1
|
||||
function! s:NERDTree.MustBeOpen()
|
||||
if !s:NERDTree.IsOpen()
|
||||
throw "NERDTree.TreeNotOpen"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"FUNCTION: s:NERDTree.New() {{{1
|
||||
function! s:NERDTree.New(path)
|
||||
let newObj = copy(self)
|
||||
let newObj.ui = g:NERDTreeUI.New(newObj)
|
||||
|
|
|
@ -185,7 +185,7 @@ function! NERDTreeRender()
|
|||
endfunction
|
||||
|
||||
function! NERDTreeFocus()
|
||||
if nerdtree#isTreeOpen()
|
||||
if g:NERDTree.IsOpen()
|
||||
call nerdtree#putCursorInTreeWin()
|
||||
else
|
||||
call g:NERDTreeCreator.TogglePrimary("")
|
||||
|
|
Loading…
Reference in New Issue
Block a user