mirror of
https://github.com/stablyai/orca.git
synced 2026-10-07 08:02:21 +00:00
Fix Ctrl+M in Linux and Windows terminals
Keep the Minimize menu item but disable its accelerator registration on Linux and Windows. Co-authored-by: Zhichang Yu <yuzhichang@gmail.com> Co-authored-by: Neil <neil@stably.ai> Co-authored-by: Ahmed Nagy <ahmednagy25t@gmail.com> Related contribution: https://github.com/stablyai/orca/pull/24143
This commit is contained in:
co-authored by
Neil
Ahmed Nagy
parent
126f7096a3
commit
f113d353cf
@@ -0,0 +1,16 @@
|
||||
export function createAppWindowMenu(
|
||||
label: string,
|
||||
isMac: boolean
|
||||
): Electron.MenuItemConstructorOptions {
|
||||
return {
|
||||
label,
|
||||
submenu: [
|
||||
{
|
||||
// Why: Electron's minimize role otherwise steals Ctrl+M from terminal apps such as Crush.
|
||||
role: 'minimize',
|
||||
...(isMac ? {} : { accelerator: '', registerAccelerator: false })
|
||||
},
|
||||
{ role: 'zoom' }
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,23 @@ function getSubmenu(
|
||||
}
|
||||
|
||||
describe('registerAppMenu', () => {
|
||||
it.each(['linux', 'win32', 'darwin'] as const)(
|
||||
'leaves Ctrl+M to the terminal while preserving macOS minimize on %s',
|
||||
(platform) => {
|
||||
vi.spyOn(process, 'platform', 'get').mockReturnValue(platform)
|
||||
registerAppMenu(buildMenuOptions())
|
||||
|
||||
const windowSubmenu = getSubmenu(getTemplate(), 'Window')
|
||||
const minimize = windowSubmenu.find((item) => item.role === 'minimize')
|
||||
expect(minimize).toEqual(
|
||||
platform === 'darwin'
|
||||
? { role: 'minimize' }
|
||||
: { role: 'minimize', accelerator: '', registerAccelerator: false }
|
||||
)
|
||||
expect(windowSubmenu.find((item) => item.role === 'zoom')).toEqual({ role: 'zoom' })
|
||||
}
|
||||
)
|
||||
|
||||
it('shows the Settings hint when the user assigns a shortcut', () => {
|
||||
registerAppMenu({
|
||||
...buildMenuOptions(),
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import type { UpdateCheckOptions } from '../../shared/update-status-types'
|
||||
import { translateMain } from '../i18n/main-i18n'
|
||||
import { createAppMenuSelectionItem } from './app-menu-selection-item'
|
||||
import { createAppWindowMenu } from './app-menu-window'
|
||||
|
||||
export type AppearanceMenuState = {
|
||||
showTasksButton: boolean
|
||||
@@ -318,10 +319,7 @@ function buildAndApplyMenu(options: RegisterAppMenuOptions): void {
|
||||
]
|
||||
}
|
||||
|
||||
const windowMenu: Electron.MenuItemConstructorOptions = {
|
||||
label: translateMain('menu.window', 'Window'),
|
||||
submenu: [{ role: 'minimize' }, { role: 'zoom' }]
|
||||
}
|
||||
const windowMenu = createAppWindowMenu(translateMain('menu.window', 'Window'), isMac)
|
||||
|
||||
const helpMenu: Electron.MenuItemConstructorOptions = {
|
||||
label: translateMain('menu.help', 'Help'),
|
||||
|
||||
Reference in New Issue
Block a user