commit 58ccd230fa5ef8cecb37b409a43c2766f580a288 parent 866df769b520c3ae020ba8ec2d87d749008433ca Author: Martin Grenfell <martin_grenfell@msn.com> Date: Fri, 13 Jun 2008 12:48:56 +1200 refactor the logic out of s:OpenExplorer() refactor out the code that actually opens the explorer window into s:OpenExplorerFor(treenode) so that we can call it separately Diffstat:
| M | plugin/NERD_tree.vim | | | 21 | +++++++++++++-------- |
1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim @@ -2064,6 +2064,18 @@ function! s:OpenDirNodeSplit(treenode) endif endfunction +" FUNCTION: s:OpenExplorerFor(treenode) {{{2 +" opens a netrw window for the given dir treenode +function! s:OpenExplorerFor(treenode) + let oldwin = winnr() + wincmd p + if oldwin == winnr() || (&modified && s:BufInWindows(winbufnr(winnr())) < 2) + 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 @@ -2992,14 +3004,7 @@ endfunction function! s:OpenExplorer() let treenode = s:GetSelectedDir() if treenode != {} - let oldwin = winnr() - wincmd p - if oldwin == winnr() || (&modified && s:BufInWindows(winbufnr(winnr())) < 2) - wincmd p - call s:OpenDirNodeSplit(treenode) - else - exec ("silent edit " . treenode.path.StrForEditCmd()) - endif + call s:OpenExplorerFor(treenode) else call s:Echo("select a node first") endif
