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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user