nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 24ad44b46fcf8a146d1f26d04a70301af429951f
parent 737ad5874077c1ab0377c805de141a244f7e1588
Author: Martin Grenfell <martin_grenfell@msn.com>
Date:   Thu, 19 Jun 2008 21:40:44 +1200

dont clobber "special" windows when opening files

if the user tries to open a file and the previous window is "special"
(eg the quickfix window or another explorer plugin) then force a new
split to be opened instead

Diffstat:
Mplugin/NERD_tree.vim | 20++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -2450,16 +2450,28 @@ endfunction
 "Args:
 "winnumber: the number of the window in question
 function! s:ShouldSplitToOpen(winnumber)
-    if &hidden
-        return 0
+    "gotta split if theres only one window (i.e. the NERD tree)
+    if winnr("$") == 1
+        return 1
     endif
-    let oldwinnr = winnr()
 
+    let oldwinnr = winnr()
     exec a:winnumber . "wincmd p"
+    let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow')
     let modified = &modified
     exec oldwinnr . "wincmd p"
 
-    return winnr("$") == 1 || (modified && s:BufInWindows(winbufnr(a:winnumber)) < 2)
+    "if its a special window e.g. quickfix or another explorer plugin then we
+    "have to split
+    if specialWindow
+        return 1
+    endif
+
+    if &hidden
+        return 0
+    endif
+
+    return modified && s:BufInWindows(winbufnr(a:winnumber)) < 2
 endfunction
 
 "FUNCTION: s:StripMarkupFromLine(line, removeLeadingSpaces){{{2