diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index fc1513b..5cdda85 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2749,8 +2749,8 @@ function! s:BindMappings() exec "nnoremap ". g:NERDTreeMapJumpLastChild ." :call JumpToLastChild()" exec "nnoremap ". g:NERDTreeMapJumpRoot ." :call JumpToRoot()" - exec "nnoremap ". g:NERDTreeMapOpenInTab ." :call OpenNodeNewTab(0)" - exec "nnoremap ". g:NERDTreeMapOpenInTabSilent ." :call OpenNodeNewTab(1)" + exec "nnoremap ". g:NERDTreeMapOpenInTab ." :call OpenInNewTab(0)" + exec "nnoremap ". g:NERDTreeMapOpenInTabSilent ." :call OpenInNewTab(1)" exec "nnoremap ". g:NERDTreeMapOpenExpl ." :call OpenExplorer()" @@ -3159,27 +3159,35 @@ function! s:OpenExplorer() endif endfunction -" FUNCTION: s:OpenNodeNewTab(stayCurrentTab) {{{2 -" Opens the currently selected file from the explorer in a -" new tab -" +" FUNCTION: s:OpenInNewTab(stayCurrentTab) {{{2 +" Opens the selected node or bookmark in a new tab " Args: " stayCurrentTab: if 1 then vim will stay in the current tab, if 0 then vim " will go to the tab where the new file is opened -function! s:OpenNodeNewTab(stayCurrentTab) +function! s:OpenInNewTab(stayCurrentTab) + let currentTab = tabpagenr() + let treenode = s:GetSelectedNode() if treenode != {} - let curTabNr = tabpagenr() exec "tabedit " . treenode.path.StrForEditCmd() if a:stayCurrentTab - exec "tabnext " . curTabNr + exec "tabnext " . currentTab endif else - call s:Echo("select a node first") + let bookmark = s:GetSelectedBookmark() + if bookmark != {} + if bookmark.path.isDirectory + exec "tabnew +NERDTreeFromBookmark\\ " . bookmark.name + else + exec "tabedit " . bookmark.path.StrForEditCmd() + endif + if a:stayCurrentTab + exec "tabnext " . currentTab + endif + endif endif endfunction - " FUNCTION: s:OpenNodeRecursively() {{{2 function! s:OpenNodeRecursively() let treenode = s:GetSelectedNode()