From f65bc62fac5123e5ea838d9fecf3211f6b906c53 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 2 Jun 2009 11:10:03 +1200 Subject: [PATCH] fix a bug that was occurring with :set nohidden previously the code didnt take &hidden (it assumed it was set) into account when determining if splitting was needed when using the o mapping on a file node --- plugin/NERD_tree.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 742c897..baf35a3 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -796,12 +796,12 @@ function! s:TreeFileNode.open() call s:exec(winnr . "wincmd w") else - if !s:isWindowUsable(winnr("#")) && s:firstNormalWindow() ==# -1 + if !s:isWindowUsable(winnr("#")) && s:firstUsableWindow() ==# -1 call self.openSplit() else try if !s:isWindowUsable(winnr("#")) - call s:exec(s:firstNormalWindow() . "wincmd w") + call s:exec(s:firstUsableWindow() . "wincmd w") else call s:exec('wincmd p') endif @@ -2517,14 +2517,15 @@ function! s:echoError(msg) call s:echo(a:msg) echohl normal endfunction -"FUNCTION: s:firstNormalWindow(){{{2 +"FUNCTION: s:firstUsableWindow(){{{2 "find the window number of the first normal window -function! s:firstNormalWindow() +function! s:firstUsableWindow() let i = 1 while i <= winnr("$") let bnum = winbufnr(i) if bnum != -1 && getbufvar(bnum, '&buftype') ==# '' \ && !getwinvar(i, '&previewwindow') + \ && (!getbufvar(bnum, '&modified') || &hidden) return i endif