vim-dispatch
vim-dispatch copied to clipboard
Expand `:Focus :.Spawn` into what will actually be called
I use :.Spawn to run the current test in a new window and automatically focus it. :Focus :.Dispatch expands :.Dispatch before setting the global focus to it, I'd expect :Focus :.Spawn to do the same.
If we collectively want this, I'd happily submit a PR if I can be put into the right direction.
I think that would be fine, although it's starting to get convoluted.
This diff got :Focus :.Spawn to expand :.Spawn to essentially run :.Dispatch - but it takes away the functionality of running :.Spawn in a new window.
Ideas?
diff --git a/autoload/dispatch.vim b/autoload/dispatch.vim
index 90cbfe2..efb528e 100644
--- a/autoload/dispatch.vim
+++ b/autoload/dispatch.vim
@@ -949,6 +949,10 @@ function! dispatch#focus_command(bang, args, count, ...) abort
let args = dispatch#focus(line(a:args[1]))[0]
elseif args =~# '^:\d\+Dispatch$'
let args = dispatch#focus(+matchstr(a:args, '\d\+'))[0]
+ elseif args =~# '^:[.$]Spawn$'
+ let args = dispatch#focus(line(a:args[1]))[0]
+ elseif args =~# '^:\d\+Spawn`$'
+ let args = dispatch#focus(+matchstr(a:args, '\d\+'))[0]
elseif args =~# '^--\S\@!' && !has_key(opts, 'compiler')
let args = matchstr(args, '\s\+\zs.*')
if empty(args)
I think what you want to do, effectively, is prepend :Spawn to the string. But make sure you end up with :Spawn -dir=... and not -dir=... :Spawn, and never add -compiler=....
Note that I retooled the existing :Focus :Dispatch support recently to fix some bugs.
Oh, you'll actually need :Spawn -wait=always to match how :.Spawn works.