Skip to content

Commit

Permalink
move nerdtree#treeExists.* methods into the NERDTree class
Browse files Browse the repository at this point in the history
  • Loading branch information
scrooloose committed Jul 17, 2014
1 parent fd14757 commit c2dd750
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
12 changes: 0 additions & 12 deletions autoload/nerdtree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion autoload/nerdtree/ui_glue.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
6 changes: 3 additions & 3 deletions lib/nerdtree/creator.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/nerdtree/key_map.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 17 additions & 1 deletion lib/nerdtree/nerdtree.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/nerdtree/tree_file_node.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c2dd750

Please sign in to comment.