skywind3000 / asyncrun.vim

:rocket: Run Async Shell Commands in Vim 8.0 / NeoVim and Output to the Quickfix Window !!
https://www.vim.org/scripts/script.php?script_id=5431
MIT License
1.84k stars 109 forks source link

focus=0 does not work as expected with tab #210

Open nick-warfield opened 3 years ago

nick-warfield commented 3 years ago

Expected Behavior

The initial tab and the final tab should be identical while focus=0, regardless of the number of tabs created, whether pos=tab or TAB, or if -reuse is enabled.

Current Behavior

The expected behavior only occurs while pos=tab, and reuse is disabled. In any other case, the final focused tab is typically the tab to the immediate left (with wrapping) of the tab used by AsyncRun.

Possible Solution

I think this is likely caused by using tabprevious to refocus to the initial tab. Instead, tabpagenr() can be used to record the initial position. Then we can just go back to the initial position at the end, adding 1 if a tab was created to the left of the initial tab.

Steps to Reproduce

  1. Open 3 or more tabs (with different names to make it easy to track)
  2. call AsyncRun with pos=TAB or --reuse enabled and focus=0