From 24ad44b46fcf8a146d1f26d04a70301af429951f Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Thu, 19 Jun 2008 21:40:44 +1200 Subject: [PATCH] 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 --- plugin/NERD_tree.vim | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index d54fa7d..64e1c1e 100644 --- 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