Skip to content

Commit

Permalink
Skip automatic copen when height <= 0
Browse files Browse the repository at this point in the history
copen and cwindow expect a positive number for the window height so we
can use the value 0 to state that the quickfix window should not be
opened or closed automatically
Allow to temporarily activate manual mode by :Copen 0
  • Loading branch information
shym committed Jul 22, 2017
1 parent 6c59a31 commit 8935746
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion autoload/dispatch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ endfunction
" Quickfix window {{{1

function! dispatch#copen(bang, count) abort
if a:count != 0
if a:count != 9999999
let g:dispatch_temporary_quickfix_height = a:count
elseif has_key(g:, 'dispatch_temporary_quickfix_height')
unlet g:dispatch_temporary_quickfix_height
Expand Down Expand Up @@ -901,6 +901,13 @@ endfunction
function! s:cwindow(request, all, copen)
call s:cgetfile(a:request, a:all)
let height = get(g:, 'dispatch_temporary_quickfix_height', get(g:, 'dispatch_quickfix_height', 10))
if height <= 0
if a:copen ==# -2
" Show the user who explicitly called Copen that something was done
echo 'QuickFix list updated'
endif
return
endif
let was_qf = s:is_quickfix()
execute 'botright' (a:copen ? 'copen' : 'cwindow') height
if !was_qf && s:is_quickfix() && a:copen !=# -2
Expand Down
2 changes: 1 addition & 1 deletion plugin/dispatch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ command! -bang -nargs=* -complete=customlist,dispatch#command_complete Spawn
command! -bang -nargs=* -complete=customlist,dispatch#command_complete Start
\ execute dispatch#start_command(<bang>0, <q-args>)

command! -bang -count -bar Copen call dispatch#copen(<bang>0, <count>)
command! -bang -count=9999999 -bar Copen call dispatch#copen(<bang>0, <count>)

function! DispatchComplete(id) abort
return dispatch#complete(a:id)
Expand Down

0 comments on commit 8935746

Please sign in to comment.