set ei=all for all wincmd calls

This commit is contained in:
Martin Grenfell 2008-12-20 00:25:45 +13:00
parent 8d20ae913a
commit 6103a308af

View File

@ -1684,6 +1684,14 @@ endfunction
function! s:completeBookmarks(A,L,P) function! s:completeBookmarks(A,L,P)
return filter(s:Bookmark.BookmarkNames(), 'v:val =~ "^' . a:A . '"') return filter(s:Bookmark.BookmarkNames(), 'v:val =~ "^' . a:A . '"')
endfunction endfunction
" FUNCTION: s:exec(cmd) {{{2
" same as :exec cmd but eventignore=all is set for the duration
function! s:exec(cmd)
let old_ei = &ei
set ei=all
exec a:cmd
let &ei = old_ei
endfunction
"FUNCTION: s:initNerdTree(name) {{{2 "FUNCTION: s:initNerdTree(name) {{{2
"Initialise the nerd tree for this tab. The tree will start in either the "Initialise the nerd tree for this tab. The tree will start in either the
"given directory, or the directory associated with the given bookmark "given directory, or the directory associated with the given bookmark
@ -1825,7 +1833,7 @@ function! NERDTreeGetCurrentNode()
let treenode = s:getSelectedNode() let treenode = s:getSelectedNode()
if winnr != winnr() if winnr != winnr()
wincmd w call s:exec('wincmd w')
endif endif
return treenode return treenode
@ -1866,9 +1874,9 @@ function! s:closeTree()
endif endif
if winnr("$") != 1 if winnr("$") != 1
execute s:getTreeWinNum() . " wincmd w" call s:exec(s:getTreeWinNum() . " wincmd w")
close close
execute "wincmd p" call s:exec("wincmd p")
else else
:q :q
endif endif
@ -2340,10 +2348,10 @@ function! s:isWindowUsable(winnumber)
endif endif
let oldwinnr = winnr() let oldwinnr = winnr()
exec a:winnumber . "wincmd p" call s:exec(a:winnumber . "wincmd p")
let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow') let specialWindow = getbufvar("%", '&buftype') != '' || getwinvar('%', '&previewwindow')
let modified = &modified let modified = &modified
exec oldwinnr . "wincmd p" call s:exec(oldwinnr . "wincmd p")
"if its a special window e.g. quickfix or another explorer plugin then we "if its a special window e.g. quickfix or another explorer plugin then we
"have to split "have to split
@ -2405,9 +2413,9 @@ endfunction
" opens a netrw window for the given dir treenode " opens a netrw window for the given dir treenode
function! s:openExplorerFor(treenode) function! s:openExplorerFor(treenode)
let oldwin = winnr() let oldwin = winnr()
wincmd p call s:exec('wincmd p')
if oldwin == winnr() || (&modified && s:bufInWindows(winbufnr(winnr())) < 2) if oldwin == winnr() || (&modified && s:bufInWindows(winbufnr(winnr())) < 2)
wincmd p call s:exec('wincmd p')
call s:openDirNodeSplit(a:treenode) call s:openDirNodeSplit(a:treenode)
else else
exec ("silent edit " . a:treenode.path.strForEditCmd()) exec ("silent edit " . a:treenode.path.strForEditCmd())
@ -2430,7 +2438,7 @@ function! s:openFileNode(treenode)
"if the file is already open in this tab then just stick the cursor in it "if the file is already open in this tab then just stick the cursor in it
let winnr = bufwinnr('^' . a:treenode.path.strForOS(0) . '$') let winnr = bufwinnr('^' . a:treenode.path.strForOS(0) . '$')
if winnr != -1 if winnr != -1
exec winnr . "wincmd w" call s:exec(winnr . "wincmd w")
else else
if !s:isWindowUsable(winnr("#")) && s:firstNormalWindow() == -1 if !s:isWindowUsable(winnr("#")) && s:firstNormalWindow() == -1
@ -2438,9 +2446,9 @@ function! s:openFileNode(treenode)
else else
try try
if !s:isWindowUsable(winnr("#")) if !s:isWindowUsable(winnr("#"))
exec s:firstNormalWindow() . "wincmd w" call s:exec(s:firstNormalWindow() . "wincmd w")
else else
wincmd p call s:exec('wincmd p')
endif endif
exec ("edit " . a:treenode.path.strForEditCmd()) exec ("edit " . a:treenode.path.strForEditCmd())
catch /^Vim\%((\a\+)\)\=:E37/ catch /^Vim\%((\a\+)\)\=:E37/
@ -2500,7 +2508,7 @@ function! s:openNodeSplit(treenode)
let below=0 let below=0
" Attempt to go to adjacent window " Attempt to go to adjacent window
exec(back) call s:exec(back)
let onlyOneWin = (winnr() == s:getTreeWinNum()) let onlyOneWin = (winnr() == s:getTreeWinNum())
@ -2529,9 +2537,9 @@ function! s:openNodeSplit(treenode)
"resize the tree window if no other window was open before "resize the tree window if no other window was open before
if onlyOneWin if onlyOneWin
let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
exec(there) call s:exec(there)
exec("silent ". splitMode ." resize ". size) exec("silent ". splitMode ." resize ". size)
wincmd p call s:exec('wincmd p')
endif endif
" Restore splitmode settings " Restore splitmode settings
@ -2608,7 +2616,7 @@ function! s:putCursorInTreeWin()
throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists" throw "NERDTree.InvalidOperationError: cant put cursor in NERD tree window, no window exists"
endif endif
exec s:getTreeWinNum() . "wincmd w" call s:exec(s:getTreeWinNum() . "wincmd w")
endfunction endfunction
"FUNCTION: s:renderBookmarks {{{2 "FUNCTION: s:renderBookmarks {{{2
@ -2725,7 +2733,7 @@ function! s:saveScreenState()
let b:NERDTreeOldPos = getpos(".") let b:NERDTreeOldPos = getpos(".")
let b:NERDTreeOldTopLine = line("w0") let b:NERDTreeOldTopLine = line("w0")
let b:NERDTreeOldWindowSize = winwidth("") let b:NERDTreeOldWindowSize = winwidth("")
exec win . "wincmd w" call s:exec(win . "wincmd w")
catch /^NERDTree.InvalidOperationError/ catch /^NERDTree.InvalidOperationError/
endtry endtry
endfunction endfunction
@ -3448,7 +3456,7 @@ function! s:previewNode(openNewWin)
else else
call s:activateNode(1) call s:activateNode(1)
end end
exec bufwinnr(currentBuf) . "wincmd w" call s:exec(bufwinnr(currentBuf) . "wincmd w")
endfunction endfunction
" FUNCTION: s:revealBookmark(name) {{{2 " FUNCTION: s:revealBookmark(name) {{{2