Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(shortcuts): show ⌘ for fixed undo/redo rows on macOS
Etienne Lescot5476eafd2472
diff --git a/src/components/video-editor/ShortcutsConfigDialog.tsx b/src/components/video-editor/ShortcutsConfigDialog.tsxindex 7118a2915..83c9d3cb3 100644--- a/src/components/video-editor/ShortcutsConfigDialog.tsx+++ b/src/components/video-editor/ShortcutsConfigDialog.tsx@@ -16,6 +16,7 @@ import {FIXED_SHORTCUTS,findConflict,formatBinding,+ formatFixedShortcut,SHORTCUT_ACTIONS,type ShortcutAction,type ShortcutBinding,@@ -212,16 +213,16 @@ export function ShortcutsConfigDialog() {<p className="text-[10px] text-[var(--muted)] mb-2 uppercase tracking-wide font-semibold">{t("fixed")}</p>- {FIXED_SHORTCUTS.map(({ i18nKey, label, display }) => (+ {FIXED_SHORTCUTS.map((shortcut) => (<div- key={i18nKey}+ key={shortcut.i18nKey}className="flex items-center justify-between py-1.5 px-1 border-b border-[var(--border-soft)] last:border-0"><span className="text-sm text-[var(--muted)]">- {t(`fixedActions.${i18nKey}`, { defaultValue: label })}+ {t(`fixedActions.${shortcut.i18nKey}`, { defaultValue: shortcut.label })}</span><kbd className="px-2 py-1 bg-[var(--surface-2)] border border-[var(--border)] rounded text-xs font-mono text-[var(--muted)] min-w-[90px] text-center">- {display}+ {formatFixedShortcut(shortcut, isMac)}</kbd></div>))}diff --git a/src/lib/shortcuts.test.ts b/src/lib/shortcuts.test.tsindex 1fe3896e8..6c0c2b3ca 100644--- a/src/lib/shortcuts.test.ts+++ b/src/lib/shortcuts.test.ts@@ -1,7 +1,10 @@import { describe, expect, it } from "vitest";import {DEFAULT_SHORTCUTS,+ FIXED_SHORTCUTS,+ type FixedShortcut,findConflict,+ formatFixedShortcut,mergeWithDefaults,SHORTCUT_ACTIONS,SHORTCUT_LABELS,@@ -45,3 +48,27 @@ describe("shortcut registry", () => {expect(merged).not.toHaveProperty("addBlur");});});++describe("formatFixedShortcut", () => {+ const fixed = (i18nKey: string): FixedShortcut => {+ const shortcut = FIXED_SHORTCUTS.find((s) => s.i18nKey === i18nKey);+ if (!shortcut) throw new Error(`no fixed shortcut ${i18nKey}`);+ return shortcut;+ };++ // The platform is an argument, not read from the host, so both branches run on every OS.+ it("shows ⌘ for undo/redo on macOS, like the configurable rows (#747)", () => {+ expect(formatFixedShortcut(fixed("undo"), true)).toBe("⌘ + Z");+ expect(formatFixedShortcut(fixed("redo"), true)).toBe("⌘ + ⇧ + Z / ⌘ + Y");+ });++ it("keeps Ctrl for undo/redo on Windows and Linux", () => {+ expect(formatFixedShortcut(fixed("undo"), false)).toBe("Ctrl + Z");+ expect(formatFixedShortcut(fixed("redo"), false)).toBe("Ctrl + Shift + Z / Ctrl + Y");+ });++ it("leaves rows without a primary modifier on their hand-written label", () => {+ expect(formatFixedShortcut(fixed("deleteSelectedAlt"), true)).toBe("Del / ⌫");+ expect(formatFixedShortcut(fixed("cycleAnnotationsBackward"), true)).toBe("Shift + Tab");+ });+});diff --git a/src/lib/shortcuts.ts b/src/lib/shortcuts.tsindex 94098a4c0..ee63a8358 100644--- a/src/lib/shortcuts.ts+++ b/src/lib/shortcuts.ts@@ -184,6 +184,15 @@ export function formatBinding(binding: ShortcutBinding, isMac: boolean): stringreturn parts.join(" + ");}+/**+ * The label a fixed row shows. Rows bound to the primary modifier are built from their bindings,+ * so macOS gets ⌘ like the configurable rows; the rest keep their hand-written `display`.+ */+export function formatFixedShortcut(shortcut: FixedShortcut, isMac: boolean): string {+ if (!shortcut.bindings.some((binding) => binding.ctrl)) return shortcut.display;+ return shortcut.bindings.map((binding) => formatBinding(binding, isMac)).join(" / ");+}+export function mergeWithDefaults(partial: Partial<ShortcutsConfig>): ShortcutsConfig {const merged = { ...DEFAULT_SHORTCUTS };for (const action of SHORTCUT_ACTIONS) {