Refactor ZenKeyboardShortcuts to add zenChangeWorkspaceBack shortcut

This commit is contained in:
mauro-balades 2024-09-21 17:25:09 +02:00
parent ae56ffc365
commit ef5da75e5e
2 changed files with 6 additions and 3 deletions

View file

@ -10,6 +10,7 @@ const kZKSActions = {
// Workspace actions
zenChangeWorkspace: ['ZenWorkspaces.changeWorkspaceShortcut()', 'zen-change-workspace', 'workspace-action'],
zenChangeWorkspaceBack: ['ZenWorkspaces.changeWorkspaceShortcut(-1)', 'zen-change-workspace-back', 'workspace-action'],
// manage actions
openNewTab: ['command:cmd_newNavigatorTabNoEvent', 'open-new-tab', 'tab-action'],
@ -129,7 +130,8 @@ const kZenDefaultShortcuts = {
zenSplitViewClose: 'Ctrl+Alt+U',
// Workspace actions
zenChangeWorkspace: 'Ctrl+Shift+E',
zenChangeWorkspace: 'Ctrl+E',
zenChangeWorkspaceBack: 'Ctrl+Shift+E',
// Compact mode actions
zenToggleCompactMode: 'Ctrl+Alt+C',

View file

@ -775,12 +775,13 @@ var ZenWorkspaces = {
await this.openEditDialog(this._contextMenuId);
},
async changeWorkspaceShortcut() {
async changeWorkspaceShortcut(offset = 1) {
// Cycle through workspaces
let workspaces = await this._workspaces();
let activeWorkspace = workspaces.workspaces.find((workspace) => workspace.used);
let workspaceIndex = workspaces.workspaces.indexOf(activeWorkspace);
let nextWorkspace = workspaces.workspaces[workspaceIndex + 1] || workspaces.workspaces[0];
// note: offset can be negative
let nextWorkspace = workspaces.workspaces[(workspaceIndex + offset + workspaces.workspaces.length) % workspaces.workspaces.length];
this.changeWorkspace(nextWorkspace);
},