fix(tui): require explicit alt bit for escape-based alt chords
Hermes-ink reports bare Escape as meta=true+escape=true on some terminals, so a configured alt+escape binding was firing on bare Esc. Require an explicit key.alt bit when the configured named key is escape so plain Esc stays plain Esc; kitty-style alt+escape still fires.
This commit is contained in:
@@ -270,6 +270,16 @@ describe('parseVoiceRecordKey (#18994)', () => {
|
|||||||
expect(isVoiceToggleKey({ ctrl: false, meta: false, super: true }, 'b', superB)).toBe(true)
|
expect(isVoiceToggleKey({ ctrl: false, meta: false, super: true }, 'b', superB)).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('alt+escape does not fire on bare Esc meta-shape', async () => {
|
||||||
|
const { isVoiceToggleKey, parseVoiceRecordKey } = await importPlatform('darwin')
|
||||||
|
const altEscape = parseVoiceRecordKey('alt+escape')
|
||||||
|
|
||||||
|
// Some terminals surface bare Esc as meta=true + escape=true.
|
||||||
|
expect(isVoiceToggleKey({ ctrl: false, escape: true, meta: true, super: false }, '', altEscape)).toBe(false)
|
||||||
|
// Explicit alt bit (kitty-style) still fires the configured chord.
|
||||||
|
expect(isVoiceToggleKey({ alt: true, ctrl: false, escape: true, meta: false, super: false }, '', altEscape)).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
it('rejects matches when Shift is held (different chord than configured)', async () => {
|
it('rejects matches when Shift is held (different chord than configured)', async () => {
|
||||||
const { isVoiceToggleKey, parseVoiceRecordKey } = await importPlatform('linux')
|
const { isVoiceToggleKey, parseVoiceRecordKey } = await importPlatform('linux')
|
||||||
|
|
||||||
|
|||||||
@@ -322,7 +322,12 @@ export const isVoiceToggleKey = (
|
|||||||
// protocols. Guard against ctrl/super bits so a chord like
|
// protocols. Guard against ctrl/super bits so a chord like
|
||||||
// Ctrl+Alt+<key> or Cmd+Alt+<key> doesn't spuriously fire the
|
// Ctrl+Alt+<key> or Cmd+Alt+<key> doesn't spuriously fire the
|
||||||
// alt binding.
|
// alt binding.
|
||||||
return (key.alt === true || key.meta) && !key.ctrl && key.super !== true
|
//
|
||||||
|
// Bare Escape on hermes-ink can arrive as ``key.meta=true`` on some
|
||||||
|
// terminals, so a configured ``alt+escape`` must not match that shape;
|
||||||
|
// require an explicit alt bit for escape chords (Copilot round-7
|
||||||
|
// follow-up on #19835).
|
||||||
|
return (key.alt === true || (key.meta && key.escape !== true)) && !key.ctrl && key.super !== true
|
||||||
case 'ctrl':
|
case 'ctrl':
|
||||||
// Require the Ctrl bit AND a clear Alt/Super so a chord like
|
// Require the Ctrl bit AND a clear Alt/Super so a chord like
|
||||||
// Ctrl+Alt+<key> / Ctrl+Cmd+<key> doesn't spuriously match
|
// Ctrl+Alt+<key> / Ctrl+Cmd+<key> doesn't spuriously match
|
||||||
|
|||||||
Reference in New Issue
Block a user