Tab.activate() as an alternative to using Go

Using the command object to execute the built-in Go command is usually fine but if the same target path is open in multiple tabs then it is not possible, as far as I know, to force a specific tab instance to be selected.

From past experience there may very well be a way that I haven't thought of (yet). However, an activate() method for the tab object would be a nice addition and would make activating a specific tab trivial.

Go TabSelect is the command for activating a particular tab.

So I can use Go TABSELECT n to select a specific tab via the command object (thanks, I didn't spot that). Can I rely on the order of lister.tabs matching the order of visible tabs? Appears to be the case.

From a quick test lister.tabs includes tabs from both sides of a dual lister but Go TABSELECT n only navigates to tabs in the source of a dual lister. No doubt I can construct code to deal with this. I would still like to see a tab.activate() method as a more straightforward way of tab navigation from within a script.

1 Like

+1

My scripts regularly end up with active tabs other than I had intended, so any help in that direction is welcome :slight_smile:

Yes.

You can use lister.tabsleft and lister.tabsright to get just the left or right tabs.

You can also select a tab directly, although this was undocumented and only used internally (but I will document it now):

cmd.RunCommand('Go TABSELECT=$' + clickData.func.sourcetab.lister.tabsleft(1));
2 Likes