vim-dispatch icon indicating copy to clipboard operation
vim-dispatch copied to clipboard

Expand `:Focus :.Spawn` into what will actually be called

Open teoljungberg opened this issue 6 years ago • 4 comments

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.

teoljungberg avatar May 17 '19 07:05 teoljungberg

I think that would be fine, although it's starting to get convoluted.

tpope avatar May 18 '19 06:05 tpope

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)

teoljungberg avatar May 18 '19 09:05 teoljungberg

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.

tpope avatar Jun 09 '19 19:06 tpope

Oh, you'll actually need :Spawn -wait=always to match how :.Spawn works.

tpope avatar Jun 09 '19 19:06 tpope