Skip to content

Commit fa95517

Browse files
committed
fix(web): 保留布局映射下的物理标点快捷键
布局映射新增字母候选时继续保留原有标点候选,不恢复错误的物理字母候选。 新增 Option 标点回归测试,54 项相关测试及 check:changed 全部通过。
1 parent a913f02 commit fa95517

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎apps/web/src/keybindings.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,22 @@ describe("resolveShortcutCommand", () => {
699699
);
700700
});
701701

702+
it("preserves physical punctuation alongside an Option-modified mapped letter", () => {
703+
for (const key of [";", "m"]) {
704+
const keybindings = compile([
705+
{ shortcut: modShortcut(key, { altKey: true }), command: "diff.toggle" },
706+
]);
707+
assert.strictEqual(
708+
resolveShortcutCommand(
709+
event({ key: "µ", code: "Semicolon", metaKey: true, altKey: true }),
710+
keybindings,
711+
{ platform: "MacIntel", keyboardLayoutMap: new Map([["Semicolon", "m"]]) },
712+
),
713+
"diff.toggle",
714+
);
715+
}
716+
});
717+
702718
it("keeps Latin event keys and unsupported layout fallbacks", () => {
703719
const keybindings = compile([
704720
{ shortcut: modShortcut("a", { altKey: true }), command: "appearance.cycle" },

‎packages/shared/src/keybindings.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ export function resolveEventKeys(
113113
keys.add(letterCode.toLowerCase());
114114
}
115115
keys.add(shortcutKey);
116+
// Layout letters supplement, rather than replace, physical punctuation shortcuts.
117+
keys.add(shortcutKeyFromEvent(event));
116118
return keys;
117119
}
118120

0 commit comments

Comments
 (0)