Skip to content
Browse files

better file edit window selection

  • Loading branch information...
1 parent dadf02f commit 0224eff58e804fd9f04d97e0dff4e9fb84b559c2 @troydm committed Oct 9, 2012
Showing with 16 additions and 2 deletions.
  1. +16 −2 plugin/easytree.vim
View
18 plugin/easytree.vim
@@ -892,9 +892,23 @@ function! s:OpenEasyTreeFile(location,fpath,mode)
wincmd k
endif
if !empty(&buftype) && a:mode == 'edit' && a:location != 'here' && !wincreated
- wincmd s
- stopinsert
+ " find windows with file buffer
+ let wnrs = filter(range(1,winnr('$')),"empty(getbufvar(winbufnr(v:val),'&buftype'))")
+ if len(wnrs) > 0
+ let wnr = winnr()
+ wincmd k
+ if !(winnr() != wnr && index(wnrs,winnr()) != -1)
+ exe wnr.'wincmd w'
+ wincmd j
+ if !(winnr() != wnr && index(wnrs,winnr()) != -1)
+ exe wnrs[0].'wincmd w'
+ endif
+ endif
+ else
+ wincmd s
+ endif
endif
+ stopinsert
if a:mode == 'edit'
exe a:mode.' '.fpath
elseif a:mode == 'sp'

0 comments on commit 0224eff

Please sign in to comment.
Something went wrong with that request. Please try again.