move nerdtree#treeExists.* methods into the NERDTree class

This commit is contained in:
Martin Grenfell 2014-07-17 20:27:21 +01:00
parent fd14757c04
commit c2dd750860
6 changed files with 24 additions and 20 deletions

View File

@ -95,18 +95,6 @@ function! nerdtree#runningWindows()
return has("win16") || has("win32") || has("win64")
endfunction
" Function: nerdtree#treeExistsForBuffer() {{{2
" Returns 1 if a nerd tree root exists in the current buffer
function! nerdtree#treeExistsForBuf()
return exists("b:NERDTreeRoot")
endfunction
" Function: nerdtree#treeExistsForTab() {{{2
" Returns 1 if a nerd tree root exists in the current tab
function! nerdtree#treeExistsForTab()
return exists("t:NERDTreeBufName")
endfunction
"FUNCTION: nerdtree#treeMarkupReg(dir) {{{2
function! nerdtree#treeMarkupReg()
if g:NERDTreeDirArrows

View File

@ -260,7 +260,7 @@ function! s:findAndRevealPath()
let g:NERDTreeShowHidden = 1
endif
if !nerdtree#treeExistsForTab()
if !g:NERDTree.ExistsForTab()
try
let cwd = g:NERDTreePath.New(getcwd())
catch /^NERDTree.InvalidArgumentsError/

View File

@ -49,7 +49,7 @@ function! s:Creator.createPrimary(name)
call path.changeToDir()
endif
if nerdtree#treeExistsForTab()
if g:NERDTree.ExistsForTab()
if nerdtree#isTreeOpen()
call nerdtree#closeTree()
endif
@ -163,7 +163,7 @@ function! s:Creator.createMirror()
return
endif
if nerdtree#treeExistsForTab() && nerdtree#isTreeOpen()
if g:NERDTree.ExistsForTab() && nerdtree#isTreeOpen()
call nerdtree#closeTree()
endif
@ -327,7 +327,7 @@ endfunction
"dir: the full path for the root node (is only used if the NERD tree is being
"initialized.
function! s:Creator.togglePrimary(dir)
if nerdtree#treeExistsForTab()
if g:NERDTree.ExistsForTab()
if !nerdtree#isTreeOpen()
call self._createTreeWin()
if !&hidden

View File

@ -85,7 +85,7 @@ function! s:KeyMap.Invoke(key)
"is in first
"
"TODO: remove this check when the vim bug is fixed
if !nerdtree#treeExistsForBuf()
if !g:NERDTree.ExistsForBuf()
return {}
endif

View File

@ -3,8 +3,24 @@
let s:NERDTree = {}
let g:NERDTree = s:NERDTree
" Function: s:NERDTree.ExistsForBuffer() {{{1
" Returns 1 if a nerd tree root exists in the current buffer
function! s:NERDTree.ExistsForBuf()
return exists("b:NERDTreeRoot")
endfunction
" Function: s:NERDTree.ExistsForTab() {{{1
" Returns 1 if a nerd tree root exists in the current tab
function! s:NERDTree.ExistsForTab()
return exists("t:NERDTreeBufName")
endfunction
function! s:NERDTree.ForCurrentBuf()
return b:NERDTree
if s:NERDTree.ExistsForBuf()
return b:NERDTree
else
return {}
endif
endfunction
function! s:NERDTree.New(path)

View File

@ -181,7 +181,7 @@ endfunction
"FUNCTION: TreeFileNode.GetRootForTab(){{{1
"get the root node for this tab
function! s:TreeFileNode.GetRootForTab()
if nerdtree#treeExistsForTab()
if g:NERDTree.ExistsForTab()
return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot')
end
return {}
@ -211,7 +211,7 @@ endfunction
"FUNCTION: TreeFileNode.isRoot() {{{1
"returns 1 if this node is b:NERDTreeRoot
function! s:TreeFileNode.isRoot()
if !nerdtree#treeExistsForBuf()
if !g:NERDTree.ExistsForBuf()
throw "NERDTree.NoTreeError: No tree exists for the current buffer"
endif