Expand `:Focus :.Spawn` into what will actually be called · Issue #270 · tpope/vim-dispatch · GitHub
Skip to content

Expand :Focus :.Spawn into what will actually be called #270

Open

Description

@teoljungberg

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.

Activity

  1. tpope commented on May 18, 2019

    @tpope
    Owner

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

  2. teoljungberg commented on May 18, 2019

    @teoljungberg
    ContributorAuthor

    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)
  3. tpope commented on Jun 9, 2019

    @tpope
    Owner

    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.

  4. tpope commented on Jun 9, 2019

    @tpope
    Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions