Jump to tab with Cmd+1-9 (Ctrl elsewhere), Firefox style

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jokin
2026-07-12 00:06:55 +02:00
co-authored by Claude Fable 5
parent aed565e424
commit c7b0418904
2 changed files with 13 additions and 0 deletions
+7
View File
@@ -120,6 +120,13 @@ export class App {
} else if (event.ctrlKey && event.key === 'Tab') {
event.preventDefault();
this.panels.cycleWorkspace(event.shiftKey ? -1 : 1);
} else if (mod && !event.shiftKey && !event.altKey) {
// ⌘1–⌘8 jump to that tab, ⌘9 to the last (Ctrl+digit elsewhere), like
// Firefox. Matched on event.code so the digit row works on any layout.
const digit = /^(?:Digit|Numpad)([1-9])$/.exec(event.code)?.[1];
if (!digit) return;
event.preventDefault();
this.panels.goToWorkspace(digit === '9' ? -1 : Number(digit) - 1);
}
}
+6
View File
@@ -326,6 +326,12 @@ export class PanelsService {
this.setActiveWorkspace(next.id);
}
/** Jump to a tab by visual position; negative counts from the end (⌘9 = last). */
goToWorkspace(index: number): void {
const target = this.workspaces().at(index);
if (target) this.setActiveWorkspace(target.id);
}
/** Tab label: "Local" for a local/local pair, else the remote titles. */
workspaceName(workspace: Workspace): string {
const remoteTitles = [workspace.left, workspace.right]