From 89357463b3ead0d7dc2d1909aa73d0f5f2327579 Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Wed, 19 Jul 2017 09:34:58 +0200 Subject: [PATCH] Skip automatic copen when height <= 0 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 --- autoload/dispatch.vim | 9 ++++++++- plugin/dispatch.vim | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/autoload/dispatch.vim b/autoload/dispatch.vim index b7ea36e..2a69a68 100644 --- a/autoload/dispatch.vim +++ b/autoload/dispatch.vim @@ -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 @@ -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 diff --git a/plugin/dispatch.vim b/plugin/dispatch.vim index 2d8a518..4b4b7c7 100644 --- a/plugin/dispatch.vim +++ b/plugin/dispatch.vim @@ -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(0, ) -command! -bang -count -bar Copen call dispatch#copen(0, ) +command! -bang -count=9999999 -bar Copen call dispatch#copen(0, ) function! DispatchComplete(id) abort return dispatch#complete(a:id)