mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 00:02:31 +00:00
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:
@@ -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() }
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user