Skip to content

Commit

Permalink
Merge pull request #50 from dyng/hotfix/restoring-fixed-window-size
Browse files Browse the repository at this point in the history
Fix bug in backup and restoring fixed windows
  • Loading branch information
dyng committed Jul 5, 2015
2 parents bf80d17 + 79be8e6 commit 3a99228
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions autoload/ctrlsf/preview.vim
Expand Up @@ -11,14 +11,15 @@ let s:PREVIEW_BUF_NAME = "__CtrlSFPreview__"
" OpenPreviewWindow()
"
func! ctrlsf#preview#OpenPreviewWindow() abort
" backup width/height of other windows
call ctrlsf#win#BackupAllWinSize()

" try to focus an existing preview window
if ctrlsf#preview#FocusPreviewWindow() != -1
return
endif

" backup width/height of other windows
" be sure doing this only when *opening new window*
call ctrlsf#win#BackupAllWinSize()

if g:ctrlsf_position == "left" || g:ctrlsf_position == "right"
let ctrlsf_width = winwidth(0)
let winsize = min([&columns-ctrlsf_width, ctrlsf_width])
Expand Down
9 changes: 5 additions & 4 deletions autoload/ctrlsf/win.vim
Expand Up @@ -27,14 +27,15 @@ func! ctrlsf#win#OpenMainWindow() abort
\ 'winnr' : winnr(),
\ }

" backup width/height of other windows
call ctrlsf#win#BackupAllWinSize()

" try to focus an existing ctrlsf window, initialize a new one if failed
if ctrlsf#win#FocusMainWindow() != -1
return
endif

" backup width/height of other windows
" be sure doing this only when *opening new window*
call ctrlsf#win#BackupAllWinSize()

if g:ctrlsf_winsize =~ '\d\{1,2}%'
if g:ctrlsf_position == "left" || g:ctrlsf_position == "right"
let winsize = &columns * str2nr(g:ctrlsf_winsize) / 100
Expand Down Expand Up @@ -272,7 +273,7 @@ endf
"""""""""""""""""""""""""""""""""
" BackupAllWinSize()
"
" Goal of BackupAllWinSize() and RestoreAllWinSize() is to restore
" Purpose of BackupAllWinSize() and RestoreAllWinSize() is to restore
" width/height of fixed sized windows such like NERDTree's. As a result, we only
" backup width/height of fixed window's to keep least side effects.
"
Expand Down

0 comments on commit 3a99228

Please sign in to comment.