Skip to content

Commit

Permalink
Version 18
Browse files Browse the repository at this point in the history
bugfix : a Taglist+minibufexplorer+ZoomWin interaction sometimes caused minibufexplorer to create a new window while ZoomWin was busy restoring the windows.  ZoomWin then issued a complaint that it didn't know how to restore the new window.  ZoomWin now temporarily disables events while it is restoring windows.
  • Loading branch information
Charles Campbell authored and vim-scripts committed Nov 6, 2010
1 parent 3e0a2f0 commit f0caaf2
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions plugin/ZoomWin.vim
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,7 @@
" ZoomWin: Brief-like ability to zoom into/out-of a window " ZoomWin: Brief-like ability to zoom into/out-of a window
" Author: Ron Aaron " Author: Ron Aaron
" modified by Charles Campbell " modified by Charles Campbell
" Version: 17 " Version: 18
" History: see :he zoomwin-history " History: see :he zoomwin-history


" --------------------------------------------------------------------- " ---------------------------------------------------------------------
Expand All @@ -26,6 +26,9 @@ au VimLeave * call <SID>CleanupSessionFile()
" The original was by Ron Aaron and has been extensively " The original was by Ron Aaron and has been extensively
" modified by Charles E. Campbell. " modified by Charles E. Campbell.
fun! ZoomWin() fun! ZoomWin()
" let g:decho_hide= 1 "Decho
" call Dfunc("ZoomWin() winbufnr(2)=".winbufnr(2))

let keep_hidden = &hidden let keep_hidden = &hidden
let keep_write = &write let keep_write = &write
if &wmh == 0 || &wmw == 0 if &wmh == 0 || &wmw == 0
Expand All @@ -42,8 +45,9 @@ fun! ZoomWin()
let sponly= s:SavePosn(0) let sponly= s:SavePosn(0)


" read session file to restore window layout " read session file to restore window layout
let ei_keep= &ei
set ei=all
exe 'silent! so '.s:sessionfile exe 'silent! so '.s:sessionfile
silent! call delete(s:sessionfile)
let v:this_session= s:sesskeep let v:this_session= s:sesskeep


if exists("s:savedposn1") if exists("s:savedposn1")
Expand All @@ -52,12 +56,16 @@ fun! ZoomWin()
call s:GotoWinNum(s:winkeep) call s:GotoWinNum(s:winkeep)
unlet s:winkeep unlet s:winkeep
endif endif
let &ei=ei_keep

if line(".") != s:origline || virtcol(".") != s:origcol if line(".") != s:origline || virtcol(".") != s:origcol
" If the cursor hasn't moved from the original position, " If the cursor hasn't moved from the original position,
" then let the position remain that of the multi-window layout " then let the position remain what it was in the original
" restoration. " multi-window layout.
call s:RestorePosn(sponly) call s:RestorePosn(sponly)
endif endif

" delete session file and variable holding its name
call delete(s:sessionfile) call delete(s:sessionfile)
unlet s:sessionfile unlet s:sessionfile
endif endif
Expand All @@ -72,6 +80,7 @@ fun! ZoomWin()
" doesn't work with the command line window (normal mode q:) " doesn't work with the command line window (normal mode q:)
if &bt == "nofile" && expand("%") == "command-line" if &bt == "nofile" && expand("%") == "command-line"
echoerr "***error*** ZoomWin doesn't work with the command line window" echoerr "***error*** ZoomWin doesn't work with the command line window"
" call Dret("ZoomWin")
return return
endif endif


Expand Down Expand Up @@ -107,6 +116,7 @@ fun! ZoomWin()
let &wmh= keep_wmh let &wmh= keep_wmh
let &wmw= keep_wmw let &wmw= keep_wmw
endif endif
" call Dret("ZoomWin")
endfun endfun


" --------------------------------------------------------------------- " ---------------------------------------------------------------------
Expand All @@ -115,6 +125,7 @@ endfun
" has the commands necessary to restore the view " has the commands necessary to restore the view
" of the current window. " of the current window.
fun! s:SavePosn(savewinhoriz) fun! s:SavePosn(savewinhoriz)
" call Dfunc("SavePosn(savewinhoriz=".a:savewinhoriz.") file<".expand("%").">")
let swline = line(".") let swline = line(".")
let swcol = col(".") let swcol = col(".")
let swwline = winline()-1 let swwline = winline()-1
Expand Down Expand Up @@ -150,34 +161,42 @@ fun! s:SavePosn(savewinhoriz)
endif endif


endif endif
" call Dret("SavePosn savedposn<".savedposn.">")
return savedposn return savedposn
endfun endfun


" --------------------------------------------------------------------- " ---------------------------------------------------------------------


" s:RestorePosn: this function restores noname and scratch windows " s:RestorePosn: this function restores noname and scratch windows
fun! s:RestorePosn(savedposn) fun! s:RestorePosn(savedposn)
" call Dfunc("RestorePosn(savedposn<".a:savedposn.">) file<".expand("%").">")
exe a:savedposn exe a:savedposn
" call Dret("RestorePosn")
endfun endfun


" --------------------------------------------------------------------- " ---------------------------------------------------------------------


" CleanupSessionFile: if you exit Vim before cleaning up the " CleanupSessionFile: if you exit Vim before cleaning up the
" supposed-to-be temporary session file " supposed-to-be temporary session file
fun! s:CleanupSessionFile() fun! s:CleanupSessionFile()
" call Dfunc("CleanupSessionFile()")
if exists("s:sessionfile") && filereadable(s:sessionfile) if exists("s:sessionfile") && filereadable(s:sessionfile)
" call Decho("sessionfile exists and is readable; deleting it")
silent! call delete(s:sessionfile) silent! call delete(s:sessionfile)
unlet s:sessionfile unlet s:sessionfile
endif endif
" call Dret("CleanupSessionFile")
endfun endfun


" --------------------------------------------------------------------- " ---------------------------------------------------------------------


" GotoWinNum: this function puts cursor into specified window " GotoWinNum: this function puts cursor into specified window
fun! s:GotoWinNum(winnum) fun! s:GotoWinNum(winnum)
" call Dfunc("GotoWinNum(winnum=".a:winnum.") winnr=".winnr())
if a:winnum != winnr() if a:winnum != winnr()
exe a:winnum."wincmd w" exe a:winnum."wincmd w"
endif endif
" call Dret("GotoWinNum")
endfun endfun


" --------------------------------------------------------------------- " ---------------------------------------------------------------------
Expand Down Expand Up @@ -221,10 +240,10 @@ finish
" --------------------------------------------------------------------- " ---------------------------------------------------------------------
" Put the help after the HelpExtractorDoc label... " Put the help after the HelpExtractorDoc label...
" HelpExtractorDoc: " HelpExtractorDoc:
*ZoomWin.txt* Zoom into/out-of a window Dec 22, 2003 *ZoomWin.txt* Zoom into/out-of a window May 24, 2004
Authors: Charles E. Campbell, Jr. *zoomwin* Authors: Charles E. Campbell, Jr. *zoomwin*
Ron Aaron Ron Aaron
Version: 17 Version: 18


============================================================================== ==============================================================================
1. Usage *zoomwin-usage* 1. Usage *zoomwin-usage*
Expand All @@ -246,6 +265,16 @@ Version: 17
============================================================================== ==============================================================================
3. History *zoomwin-history* 3. History *zoomwin-history*


v18 May 20, 2004 : * bugfix - didn't adversely affect anything, but
ZoomWin was deleting its session file twice.
* bugfix -- a multi-source file + minibufexplorer
+ Taglist interaction bug -- minibufexplorer's
autocmd events were firing, generating a new
window while ZoomWin was attempting to restore
the display. ZoomWin didn't have restoration
information for the new window and so reported
an error. Events are now temporarily disabled
while ZoomWin is restoring the layout.
v17 Mar 26, 2004 : ZoomWin command installed. Works nicely with v17 Mar 26, 2004 : ZoomWin command installed. Works nicely with
taglist: vim +Tlist +ZoomWin filename taglist: vim +Tlist +ZoomWin filename
v16 Dec 22, 2003 : handles bufhidden and nobl windows (TagList support). v16 Dec 22, 2003 : handles bufhidden and nobl windows (TagList support).
Expand Down

0 comments on commit f0caaf2

Please sign in to comment.