Skip to content

Commit

Permalink
fix bug: qf/loc window grows in size when closing preview window
Browse files Browse the repository at this point in the history
This seems to be a common bug:

mileszs/ack.vim#150
vim-syntastic/syntastic#1489

For me, the issue occurs when I have NERDTree open; each time I close
the preview window, the qf/loc window grows to fill the space that was
previously filled by the preview window. This will continue to occur on
each preview window close, until the qf/loc window takes up the entire
screen.

The fix introduced by this patch is to force the qf/loc window back to
its original size each time the preview window closed. This fix is a bit
hacky, but it seems to work well.
  • Loading branch information
matt1003 committed May 16, 2018
1 parent 904f28e commit 70f64a2
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions after/ftplugin/qf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
" Version: 1.0
" Website: https://github.com/ronakg/quickr-preview.vim

" ClosePreviewWindow() {{
"
" This function closes the preview window while ensuring that the
" quickfix/location window maintain the correct size. This should
" be called while in the quickfix/location window.
"
function! ClosePreviewWindow()
let l:orig_win_height = winheight(0)
pclose
exe 'resize' l:orig_win_height
endfunction
" }}

" QFList() {{
"
" Operate on an entry in quickfix list
Expand All @@ -13,7 +26,7 @@ function! QFList(linenr)
return
endif

pclose
call ClosePreviewWindow()

if a:linenr == b:prvlinenr
let b:prvlinenr = 0
Expand Down Expand Up @@ -60,7 +73,7 @@ function! HandleEnterQuickfix(linenr)
endif

let l:entry = b:qflist[a:linenr - 1]
pclose
call ClosePreviewWindow()

" Check whether this buffer is already open outside the preview window,
" if not then delete it to clear out any persisting flags (unlisted etc)
Expand Down

0 comments on commit 70f64a2

Please sign in to comment.