mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 19:33:50 -05:00
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
This commit is contained in:
@@ -2064,6 +2064,18 @@ function! s:OpenDirNodeSplit(treenode)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
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
|
"FUNCTION: s:OpenFileNode(treenode) {{{2
|
||||||
"Open the file represented by the given node in the current window, splitting
|
"Open the file represented by the given node in the current window, splitting
|
||||||
"the window if needed
|
"the window if needed
|
||||||
@@ -2992,14 +3004,7 @@ endfunction
|
|||||||
function! s:OpenExplorer()
|
function! s:OpenExplorer()
|
||||||
let treenode = s:GetSelectedDir()
|
let treenode = s:GetSelectedDir()
|
||||||
if treenode != {}
|
if treenode != {}
|
||||||
let oldwin = winnr()
|
call s:OpenExplorerFor(treenode)
|
||||||
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
|
|
||||||
else
|
else
|
||||||
call s:Echo("select a node first")
|
call s:Echo("select a node first")
|
||||||
endif
|
endif
|
||||||
|
|||||||
Reference in New Issue
Block a user