move nerdtree#treeExists.* methods into the NERDTree class
This commit is contained in:
parent
fd14757c04
commit
c2dd750860
@ -95,18 +95,6 @@ function! nerdtree#runningWindows()
|
|||||||
return has("win16") || has("win32") || has("win64")
|
return has("win16") || has("win32") || has("win64")
|
||||||
endfunction
|
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(dir) {{{2
|
||||||
function! nerdtree#treeMarkupReg()
|
function! nerdtree#treeMarkupReg()
|
||||||
if g:NERDTreeDirArrows
|
if g:NERDTreeDirArrows
|
||||||
|
@ -260,7 +260,7 @@ function! s:findAndRevealPath()
|
|||||||
let g:NERDTreeShowHidden = 1
|
let g:NERDTreeShowHidden = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !nerdtree#treeExistsForTab()
|
if !g:NERDTree.ExistsForTab()
|
||||||
try
|
try
|
||||||
let cwd = g:NERDTreePath.New(getcwd())
|
let cwd = g:NERDTreePath.New(getcwd())
|
||||||
catch /^NERDTree.InvalidArgumentsError/
|
catch /^NERDTree.InvalidArgumentsError/
|
||||||
|
@ -49,7 +49,7 @@ function! s:Creator.createPrimary(name)
|
|||||||
call path.changeToDir()
|
call path.changeToDir()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if nerdtree#treeExistsForTab()
|
if g:NERDTree.ExistsForTab()
|
||||||
if nerdtree#isTreeOpen()
|
if nerdtree#isTreeOpen()
|
||||||
call nerdtree#closeTree()
|
call nerdtree#closeTree()
|
||||||
endif
|
endif
|
||||||
@ -163,7 +163,7 @@ function! s:Creator.createMirror()
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if nerdtree#treeExistsForTab() && nerdtree#isTreeOpen()
|
if g:NERDTree.ExistsForTab() && nerdtree#isTreeOpen()
|
||||||
call nerdtree#closeTree()
|
call nerdtree#closeTree()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -327,7 +327,7 @@ endfunction
|
|||||||
"dir: the full path for the root node (is only used if the NERD tree is being
|
"dir: the full path for the root node (is only used if the NERD tree is being
|
||||||
"initialized.
|
"initialized.
|
||||||
function! s:Creator.togglePrimary(dir)
|
function! s:Creator.togglePrimary(dir)
|
||||||
if nerdtree#treeExistsForTab()
|
if g:NERDTree.ExistsForTab()
|
||||||
if !nerdtree#isTreeOpen()
|
if !nerdtree#isTreeOpen()
|
||||||
call self._createTreeWin()
|
call self._createTreeWin()
|
||||||
if !&hidden
|
if !&hidden
|
||||||
|
@ -85,7 +85,7 @@ function! s:KeyMap.Invoke(key)
|
|||||||
"is in first
|
"is in first
|
||||||
"
|
"
|
||||||
"TODO: remove this check when the vim bug is fixed
|
"TODO: remove this check when the vim bug is fixed
|
||||||
if !nerdtree#treeExistsForBuf()
|
if !g:NERDTree.ExistsForBuf()
|
||||||
return {}
|
return {}
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -3,8 +3,24 @@
|
|||||||
let s:NERDTree = {}
|
let s:NERDTree = {}
|
||||||
let g:NERDTree = 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()
|
function! s:NERDTree.ForCurrentBuf()
|
||||||
return b:NERDTree
|
if s:NERDTree.ExistsForBuf()
|
||||||
|
return b:NERDTree
|
||||||
|
else
|
||||||
|
return {}
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:NERDTree.New(path)
|
function! s:NERDTree.New(path)
|
||||||
|
@ -181,7 +181,7 @@ endfunction
|
|||||||
"FUNCTION: TreeFileNode.GetRootForTab(){{{1
|
"FUNCTION: TreeFileNode.GetRootForTab(){{{1
|
||||||
"get the root node for this tab
|
"get the root node for this tab
|
||||||
function! s:TreeFileNode.GetRootForTab()
|
function! s:TreeFileNode.GetRootForTab()
|
||||||
if nerdtree#treeExistsForTab()
|
if g:NERDTree.ExistsForTab()
|
||||||
return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot')
|
return getbufvar(t:NERDTreeBufName, 'NERDTreeRoot')
|
||||||
end
|
end
|
||||||
return {}
|
return {}
|
||||||
@ -211,7 +211,7 @@ endfunction
|
|||||||
"FUNCTION: TreeFileNode.isRoot() {{{1
|
"FUNCTION: TreeFileNode.isRoot() {{{1
|
||||||
"returns 1 if this node is b:NERDTreeRoot
|
"returns 1 if this node is b:NERDTreeRoot
|
||||||
function! s:TreeFileNode.isRoot()
|
function! s:TreeFileNode.isRoot()
|
||||||
if !nerdtree#treeExistsForBuf()
|
if !g:NERDTree.ExistsForBuf()
|
||||||
throw "NERDTree.NoTreeError: No tree exists for the current buffer"
|
throw "NERDTree.NoTreeError: No tree exists for the current buffer"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user