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
Open 3 or more tabs (with different names to make it easy to track)
call AsyncRun with pos=TAB or --reuse enabled and focus=0
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