Terminal: Add keybinding: moveTabLeft, moveTabRight

Created on 15 Nov 2019  路  16Comments  路  Source: microsoft/terminal

Description of the new feature/enhancement

The list of implemented keybindings is missing the option of moving tabs to the left/right.

I did try and look for this request in other places, but the closest I could find was PR #3478, which implements this functionality as mouse-input by drag & drop, but as far as I could tell it is still missing as keyboard shortcuts.

I saw this mentioned in another thread, but again I was not able to tell if this was just proposed as a request or actually solved.

Proposed technical implementation details (optional)

This should be straightforward: Get the keywords moveTabLeft and moveTabRight in to the list of supported keybindings.

Area-User Interface Easy Starter Help Wanted Issue-Task Product-Terminal Resolution-Fix-Committed

Most helpful comment

Some teasing..
MoveTabs

Now I need to understand if something was broken

All 16 comments

I don't hate this idea.

With #3391 merged, we could probably make the ShortcutAction moveTab, so you could do the following:

    { "keys": [ "alt+1" ], "command": { "action": "moveTab", "direction": "left" } },
    { "keys": [ "alt+2" ], "command": { "action": "moveTab", "direction": "right" } },
    { "keys": [ "alt+3" ], "command": { "action": "moveTab", "direction": "left", "amount": 1000 } },
    { "keys": [ "alt+4" ], "command": { "action": "moveTab", "direction": "right", "amount": 3 } },

I don't know _why_ someone would necessarily want to be able to move by a custom amount, but the Alt+3 binding above could be used to move a tab all the way to the first position, so that's an idea.

I'm not sure what the Help Wanted tag means but if you are looking for more use-cases, then I can provide one.

I have set up keybindings for navigating tabs as:

"keybindings": [
    { "command": "prevTab", "keys": ["ctrl+pageup"] },
    { "command": "nextTab", "keys": ["ctrl+pagedown"] }
]

I would 鉂わ笍 to setup something similar to move tabs in the same manner.
E.g.

"keybindings": [
    { "command": "prevTab", "keys": ["ctrl+pageup"] },
    { "command": "nextTab", "keys": ["ctrl+pagedown"] },
    { "command": "moveTabBackward", "keys": ["ctrl+shift+pageup"] },
    { "command": "moveTabForward", "keys": ["ctrl+shift+pagedown"] }
]

I do not think that it should cycle through. Rather moving a tab backwards (in LTR languages) should stop at position 0. So that press and holding ctrl+shift+pageup will bring the tab to the first position (far left in LTR). Reversed for ctrl+shift+pagedown also being true of course.

The reason for using "moveTabBackward"/"moveTabForward" instead of "moveTabLeft"/"moveTabRight" is that, in my limited knowledge, in RTL languages (Arabic, Hebrew, Parsi, etc) pageup and pagedown are expected to work in reversed order of LTR languages (European).

@dotnetCarpenter Although I don't believe we'll ever see an RTL layout for the terminal (coming from a Hebrew user here), it's still probably a good idea to name these bindings as "forward" / "backward".

Pls finish this proposal, move tabs left/right is one of the latest feature missing 馃憣, WT has almost everything, I'm waiting for this proposal too, thx WT ftv

@zadjii-msft - I can do it. Wondering if we have issues with MRU implementation

Thanks for volunteering! I bet that the MRU ordering definitely will need to be updated as we move the tabs around.

Oh yea that'll be tricky, because after we re-order the tab, we'll need to update the indicies of every other entry in the MRU list.

Though, presumably drag/dropping tabs already does this right, so we should be able to re-use that code...

edit:
Let's make sure to make it forward/backward, as @dotnetCarpenter called out above

    { "command": { "action": "moveTab", "direction": "forward" } },
    { "command": { "action": "moveTab", "direction": "backward" } },
    { "command": { "action": "moveTab", "direction": "forward", "amount": 1000 } },
    { "command": { "action": "moveTab", "direction": "backward", "amount": 3 } },

Thanks for volunteering! I bet that the MRU ordering definitely will need to be updated as we move the tabs around.

Oh yea that'll be tricky, because after we re-order the tab, we'll need to update the indicies of every other entry in the MRU list.

Though, presumably drag/dropping tabs already does this right, so we should be able to re-use that code...

edit:
Let's make sure to make it forward/backward, as @dotnetCarpenter called out above

    { "command": { "action": "moveTab", "direction": "forward" } },
    { "command": { "action": "moveTab", "direction": "backward" } },
    { "command": { "action": "moveTab", "direction": "forward", "amount": 1000 } },
    { "command": { "action": "moveTab", "direction": "backward", "amount": 3 } },

Probably the direction should be: "forward", "backward", "front", "back".
While "forward" and "backward" will have an "amount" field?

While "forward" and "backward" will have an "amount" field?

Earlier in this thread was written this:

I don't know why someone would necessarily want to be able to move by a custom amount, but the Alt+3 binding above could be used to move a tab all the way to the first position, so that's an idea.

So to be able to move a tab to the first/last position.

I guess that does raise good points. Does { "action": "moveTab", "direction": "backward", "amount": 3 } _really_ have value? Clearly the front/back cases make sense, and they're more semantic than { "action": "moveTab", "direction": "forward", "amount": 1000 } as a synonym for "move to the first position". Using a ridiculous amount for that action _works_, but it sure seems like front would be more obvious in what it's meant to accomplish.

I suppose it does make more sense to start with a front/back value for direction, and add an amount if there's someone who really wants to be able to move tabs with a keybinding, multiple indices at a time (but not all the way to the front/back).

I think amount is unnecessary ( of course it can be implemented too ).

As you propose, much better would be to add a bool flag, which indicates a move to the front/back position and would be good to have the flag with one name, I can't find a good English word for this flag, something that describes the beginning and the end in one word.

A good start is to implement the basic functionality and this can be added and decided later ( moving to the first/last position ), it is not so important.

OK. I will start with a basic functionality of moving one tab left/right - let's see if I even succeed :blush:

OK. I will start with a basic functionality of moving one tab left/right - let's see if I even succeed 馃槉

Currently reordering is implemented but only with the mouse, so I would start to look at which functions are used in dragStart / dragEnd handlers, investigate how they work, then look how are implemented keyboard actions, then I would create empty keyboard action and try to reuse logic and functions from dragStart / dragEnd handlers. 馃榿
I'm pretty sure that it will not be that simple 馃馃檪

Some teasing..
MoveTabs

Now I need to understand if something was broken

I'm pretty sure that it will not be that simple 馃馃檪

image

Thx, I'm happy about this 馃憣

Was this page helpful?
0 / 5 - 0 ratings