nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 808850a4645ddba76657ee35b21120cb9d58a185
parent 24ad44b46fcf8a146d1f26d04a70301af429951f
Author: Martin Grenfell <martin_grenfell@msn.com>
Date:   Thu, 19 Jun 2008 22:35:36 +1200

dont open a file twice in the same tab with o mapping

if the user tells the nerd tree to open a file (without splitting), and
that file is already open in the current tab, then just stick the cursor
in the existing window for the file

Diffstat:
Mplugin/NERD_tree.vim | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -2104,7 +2104,12 @@ endfunction
 function! s:OpenFileNode(treenode)
     call s:PutCursorInTreeWin()
 
-    if s:ShouldSplitToOpen(winnr("#"))
+    "if the file is already open in this tab then just stick the cursor in it
+    let winnr = bufwinnr(a:treenode.path.StrForOS(0))
+    if winnr != -1
+        exec winnr . "wincmd w"
+
+    elseif s:ShouldSplitToOpen(winnr("#"))
         call s:OpenFileNodeSplit(a:treenode)
     else
         try