Fix Ctrl+Tab switcher selection on release (#5116)

This commit is contained in:
Parker Rex
2026-06-10 22:11:17 -07:00
committed by GitHub
parent a428d60dac
commit c2b68cac74
8 changed files with 383 additions and 92 deletions
+44
View File
@@ -4,6 +4,7 @@ navigation, new-workspace tab routing). Splitting across files would
fragment the test of a single pure function. */
import { describe, expect, it } from 'vitest'
import {
isRecentTabSwitcherCommitRelease,
isWindowShortcutModifierChord,
matchesRecentTabSwitcherChord,
resolveWindowShortcutAction,
@@ -329,6 +330,49 @@ describe('resolveWindowShortcutAction', () => {
expect(matchesRecentTabSwitcherChord(eventInput, 'linux')).toBe(true)
})
it('recognizes Ctrl+Tab commit releases across Electron surfaces', () => {
expect(
isRecentTabSwitcherCommitRelease({
type: 'keyUp',
code: 'ControlLeft',
key: 'Control',
control: false
})
).toBe(true)
expect(
isRecentTabSwitcherCommitRelease({
type: 'keyUp',
code: 'Control',
key: 'Control',
control: false
})
).toBe(true)
expect(
isRecentTabSwitcherCommitRelease({
type: 'keyUp',
code: 'Tab',
key: 'Tab',
control: false
})
).toBe(true)
expect(
isRecentTabSwitcherCommitRelease({
type: 'keyUp',
code: 'Tab',
key: 'Tab',
control: true
})
).toBe(false)
expect(
isRecentTabSwitcherCommitRelease({
type: 'keyup',
code: 'ControlLeft',
key: 'Control',
ctrlKey: false
})
).toBe(true)
})
it('accepts all supported zoom key variants', () => {
const zoomInCases: WindowShortcutInput[] = [
{ key: '=', meta: true, control: false, alt: false, shift: false },
+26
View File
@@ -92,6 +92,32 @@ export function matchesRecentTabSwitcherChord(
)
}
function isControlKey(input: WindowShortcutInput): boolean {
return (
input.code === 'ControlLeft' ||
input.code === 'ControlRight' ||
input.code === 'Control' ||
input.key === 'Control'
)
}
function isTabKey(input: WindowShortcutInput): boolean {
return input.code === 'Tab' || input.key === 'Tab'
}
export function isRecentTabSwitcherCommitRelease(input: WindowShortcutInput): boolean {
if (input.type !== 'keyUp' && input.type !== 'keyup') {
return false
}
if (isControlKey(input)) {
return true
}
const control = input.control ?? input.ctrlKey
// Why: some Electron surfaces report the final Ctrl+Tab release as Tab
// keyup after Control is already up, so commit instead of stranding the UI.
return isTabKey(input) && control === false
}
function actionMatches(
actionId: KeybindingActionId,
input: WindowShortcutInput,