Fix Ctrl+Z in Windows and Linux terminals (#13398)

* fix(terminal): preserve Windows undo chords

* fix(terminal): keep undo menu hints unregistered
This commit is contained in:
Brennan Benson
2026-08-09 18:14:39 -07:00
committed by GitHub
parent ac830689c4
commit b2e29a2247
2 changed files with 26 additions and 2 deletions
+20
View File
@@ -259,6 +259,26 @@ describe('registerAppMenu', () => {
}
)
it.each(['darwin', 'linux', 'win32'] as const)(
'preserves terminal undo and redo chords on %s',
(platform) => {
vi.spyOn(process, 'platform', 'get').mockReturnValue(platform)
registerAppMenu(buildMenuOptions())
const editSubmenu = getSubmenu(getTemplate(), 'Edit')
const expectedRegistration = platform === 'darwin' ? undefined : false
const undoItem = editSubmenu.find((item) => item.role === 'undo')
const redoItem = editSubmenu.find((item) => item.role === 'redo')
expect(undoItem?.accelerator).toBeUndefined()
expect(redoItem?.accelerator).toBeUndefined()
expect(undoItem && 'registerAccelerator' in undoItem).toBe(platform !== 'darwin')
expect(redoItem && 'registerAccelerator' in redoItem).toBe(platform !== 'darwin')
expect(undoItem?.registerAccelerator).toBe(expectedRegistration)
expect(redoItem?.registerAccelerator).toBe(expectedRegistration)
}
)
it('keeps selection actions native in a focused guest webview', () => {
const send = vi.fn()
const guestContents = { copy: vi.fn(), selectAll: vi.fn() }
+6 -2
View File
@@ -167,11 +167,15 @@ function buildAndApplyMenu(options: RegisterAppMenuOptions): void {
]
}
// Why: keep native menu hints while letting non-macOS Ctrl+Z/Ctrl+Y reach the focused terminal or DOM control.
const undoRedoOptions: Electron.MenuItemConstructorOptions = isMac
? {}
: { registerAccelerator: false }
const editMenu: Electron.MenuItemConstructorOptions = {
label: translateMain('menu.edit', 'Edit'),
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ role: 'undo', ...undoRedoOptions },
{ role: 'redo', ...undoRedoOptions },
{ type: 'separator' },
{ role: 'cut' },
createAppMenuSelectionItem({