Skip to content

Commit 9255742

Browse files
committed
Allow :0Dispatch to bypass focus
Really both focusing and default tasks belong in separate plugins, but until that happens, provide a way to override the focus with the buffer default. One can also use 2:Dispatch, which is convenient with a map.
1 parent 4caf963 commit 9255742

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

autoload/dispatch.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ function! dispatch#compile_command(bang, args, count) abort
402402
let args = a:args
403403
else
404404
let args = '_'
405-
for vars in [b:, g:, t:, w:]
405+
for vars in a:count < 0 ? [b:, g:, t:, w:] : [b:]
406406
if has_key(vars, 'dispatch') && type(vars.dispatch) == type('')
407407
let args = vars.dispatch
408408
endif
@@ -412,7 +412,7 @@ function! dispatch#compile_command(bang, args, count) abort
412412
if args =~# '^!'
413413
return 'Start' . (a:bang ? '!' : '') . ' ' . args[1:-1]
414414
elseif args =~# '^:.'
415-
return (a:count ? a:count : '').substitute(args[1:-1], '\>', (a:bang ? '!' : ''), '')
415+
return (a:count > 0 ? a:count : '').substitute(args[1:-1], '\>', (a:bang ? '!' : ''), '')
416416
endif
417417
let executable = matchstr(args, '\S\+')
418418

plugin/dispatch.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ endif
88
let g:loaded_dispatch = 1
99

1010
command! -bang -nargs=* -range=0 -complete=customlist,dispatch#command_complete Dispatch
11-
\ execute dispatch#compile_command(<bang>0, <q-args>, <count>)
11+
\ execute dispatch#compile_command(<bang>0, <q-args>,
12+
\ <line1> && !<count> ? -1 : <line1> == <line2> ? <count> : 0)
1213

1314
command! -bang -nargs=* -complete=customlist,dispatch#command_complete FocusDispatch
1415
\ execute dispatch#focus_command(<bang>0, <q-args>)

0 commit comments

Comments
 (0)