mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 21:39:58 +02:00
Refactor ZenKeyboardShortcuts to add zenChangeWorkspaceBack shortcut
This commit is contained in:
parent
ae56ffc365
commit
ef5da75e5e
2 changed files with 6 additions and 3 deletions
|
@ -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',
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue