nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 78aa2fa1dbdef0c02f970c3e1b968e39dff0bf6a
parent 111e309507fdaaa16ea86d4fce9818a4f5faf45e
Author: Martin Grenfell <martin_grenfell@msn.com>
Date:   Tue,  6 Jan 2009 13:51:42 +1300

move the openExplorerFor code into the TreeDirNode

Diffstat:
Mplugin/NERD_tree.vim | 41+++++++++++++++--------------------------
1 file changed, 15 insertions(+), 26 deletions(-)
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -1053,6 +1053,19 @@ function! s:TreeDirNode.open()
     endif
 endfunction
 
+" FUNCTION: TreeDirNode.openExplorer() {{{3
+" opens an explorer window for this node in the previous window (could be a
+" nerd tree or a netrw)
+function! s:TreeDirNode.openExplorer()
+    let oldwin = winnr()
+    call s:exec('wincmd p')
+    if oldwin == winnr() || (&modified && s:bufInWindows(winbufnr(winnr())) < 2)
+        call s:exec('wincmd p')
+        call self.openSplit()
+    else
+        exec ("silent edit " . self.path.strForEditCmd())
+    endif
+endfunction
 "FUNCTION: TreeDirNode.openRecursively() {{{3
 "Opens this treenode and all of its children whose paths arent 'ignored'
 "because of the file filters.
@@ -2545,30 +2558,6 @@ function! s:jumpToChild(direction)
 endfunction
 
 
-"FUNCTION: s:openDirNodeSplit(treenode) {{{2
-"Open the file represented by the given node in a new window.
-"No action is taken for file nodes
-"
-"ARGS:
-"treenode: file node to open
-function! s:openDirNodeSplit(treenode)
-    if a:treenode.path.isDirectory == 1
-        call a:treenode.openSplit()
-    endif
-endfunction
-
-" FUNCTION: s:openExplorerFor(treenode) {{{2
-" opens a netrw window for the given dir treenode
-function! s:openExplorerFor(treenode)
-    let oldwin = winnr()
-    call s:exec('wincmd p')
-    if oldwin == winnr() || (&modified && s:bufInWindows(winbufnr(winnr())) < 2)
-        call s:exec('wincmd p')
-        call s:openDirNodeSplit(a:treenode)
-    else
-        exec ("silent edit " . a:treenode.path.strForEditCmd())
-    endif
-endfunction
 "FUNCTION: s:openFileNode(treenode) {{{2
 "Open the file represented by the given node in the current window, splitting
 "the window if needed
@@ -3429,7 +3418,7 @@ function! s:openBookmark(name)
         let targetNode = s:TreeFileNode.New(bookmark.path)
     endtry
     if targetNode.path.isDirectory
-        call s:openExplorerFor(targetNode)
+        call targetNode.openExplorer()
     else
         call s:openFileNode(targetNode)
     endif
@@ -3456,7 +3445,7 @@ endfunction
 function! s:openExplorer()
     let treenode = s:getSelectedDir()
     if treenode != {}
-        call s:openExplorerFor(treenode)
+        call treenode.openExplorer()
     else
         call s:echo("select a node first")
     endif