Reputation: 710
I use keyboard shortcuts to cycle through tabs using workbench.action.nextEditorInGroup
and workbench.action.previousEditorInGroup
which works great for me except that they "wrap". In other words, if you are on the first tab of an editor group and you execute workbench.action.previousEditorInGroup
it will focus the last editor in the group. There doesn't seem to be a setting for preventing this behavior (though if you know of one that would solve my problem!), so I'm hoping to achieve it through the when
clause in the keybindings.
I found activeEditorGroupIndex
and activeEditorGroupLast
, but I have not found a similar clause for the editor index. Does anyone know of one?
Here's my current bindings:
{ "key": "ctrl+.", "command": "workbench.action.nextEditorInGroup", "when": "editorFocus" },
{ "key": "ctrl+,", "command": "workbench.action.previousEditorInGroup", "when": "editorFocus" },
What I'd like is something like:
{ "key": "ctrl+.", "command": "workbench.action.nextEditorInGroup", "when": "editorFocus && !activeEditorLast" },
{ "key": "ctrl+,", "command": "workbench.action.previousEditorInGroup", "when": "editorFocus && !activeEditorIndex == 0" },
Upvotes: 2
Views: 288
Reputation: 182331
These new context keys are in v1.66:
activeEditorIsFirstInGroup
activeEditorIsLastInGroup
New context keys were added to figure out if an editor is first or last in an editor group:
activeEditorIsFirstInGroup
- Whether the active editor is the first one in its group.activeEditorIsLastInGroup
- Whether the active editor is the last one in its group.
I would think these keybindings should work for you:
{ "key": "ctrl+.", "command": "workbench.action.nextEditorInGroup", "when": "editorFocus && !activeEditorIsLastInGroup" },
{ "key": "ctrl+,", "command": "workbench.action.previousEditorInGroup", "when": "editorFocus && !activeEditorIsFirstInGroup" }
Upvotes: 3