mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-14 12:10:45 +03:00
fix(desktop): preserve Windows editing shortcuts (#46336)
This commit is contained in:
committed by
GitHub
Unverified
parent
a1925de0c1
commit
8890294bf0
@@ -298,7 +298,7 @@ export function Titlebar(props: {
|
||||
id: "home.toggle",
|
||||
title: language.t("home.title"),
|
||||
category: language.t("command.category.view"),
|
||||
keybind: "mod+b",
|
||||
keybind: windows() ? "alt+home" : "mod+b",
|
||||
hidden: true,
|
||||
onSelect: toggleHome,
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { DESKTOP_MENU } from "@/shell/commands/desktop-menu"
|
||||
import { windowsMenuAccelerator } from "./windows-menu"
|
||||
|
||||
describe("Windows app menu", () => {
|
||||
@@ -11,4 +12,16 @@ describe("Windows app menu", () => {
|
||||
test("ignores the accelerator without its modifiers", () => {
|
||||
expect(windowsMenuAccelerator(new KeyboardEvent("keydown", { key: "N" }))).toBeUndefined()
|
||||
})
|
||||
|
||||
test.each(["v", "c", "x", "a", "z", "y"])("leaves Ctrl+%s to the focused editor", (key) => {
|
||||
expect(windowsMenuAccelerator(new KeyboardEvent("keydown", { key, ctrlKey: true }))).toBeUndefined()
|
||||
})
|
||||
|
||||
test("preserves the paste menu action and shortcut label", () => {
|
||||
expect(
|
||||
DESKTOP_MENU.flatMap((menu) => menu.items ?? []).find(
|
||||
(entry) => entry.type === "item" && entry.action === "edit.paste",
|
||||
),
|
||||
).toMatchObject({ action: "edit.paste", accelerator: { windows: "Ctrl+V" } })
|
||||
})
|
||||
})
|
||||
|
||||
@@ -16,6 +16,8 @@ import { useLanguage } from "@/runtime/i18n/language"
|
||||
|
||||
const accelerators = DESKTOP_MENU.flatMap((menu) => menu.items ?? []).flatMap((entry) => {
|
||||
if (entry.type === "separator" || !entry.action || !entry.accelerator?.windows) return []
|
||||
// Let the focused editor handle editing shortcuts without restoring stale menu focus.
|
||||
if (entry.action.startsWith("edit.")) return []
|
||||
return [{ action: entry.action, keybind: parseKeybind(entry.accelerator.windows) }]
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user