дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
fix(keymap): match remaining letter shortcuts by typed character (#292)
#291 named letter keys by the typed character (e.key) when Alt is not held, so AZERTY Ctrl+Z is no longer Ctrl+W. Hard-coded handlers still compared the physical KeyboardEvent.code. A shared letterOf(e) in platform/keymap.ts now backs strokeOf and those handlers: - terminal Ctrl+Shift+C / V / T (copy, paste, new tab) and Ctrl+letter control codes - Run/Debug Configurations Ctrl/Cmd+N - browser shortcut guards (blocked reload/print etc.) Alt combos keep the physical key (Option / AltGr type symbols).
Цей коміт міститься в:
1 джерело
d1a597898d
коміт
aeec0e6759
8 files changed
+64
-18
No files matched your search
@@ -56,4 +56,14 @@ describe("browser guards: context menu", () => {
|
||||
rightClick(p);
|
||||
expect(useContextMenuStore.getState().menu).toBeNull();
|
||||
});
|
||||
|
||||
it("blocks browser shortcuts by typed letter", () => {
|
||||
const press = (init: KeyboardEventInit) => {
|
||||
const e = new KeyboardEvent("keydown", { bubbles: true, cancelable: true, ...init });
|
||||
window.dispatchEvent(e);
|
||||
return e.defaultPrevented;
|
||||
};
|
||||
expect(press({ key: "p", code: "KeyR", ctrlKey: true })).toBe(true);
|
||||
expect(press({ key: "l", code: "KeyP", ctrlKey: true })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -5,6 +5,7 @@
|
||||
* shortcuts stay untouched. A right-click no component handled on selected or
|
||||
* selectable read-only text gets IDEA's Copy menu instead of nothing.
|
||||
*/
|
||||
import { letterOf } from "@/platform/keymap";
|
||||
import { copyMenuFor, showContextMenu, useContextMenuStore } from "@/ui";
|
||||
|
||||
const BLOCKED = new Set([
|
||||
@@ -23,13 +24,7 @@ const BLOCKED = new Set([
|
||||
const RELOAD = new Set(["Meta+R", "Meta+Shift+R", "Ctrl+R", "Ctrl+Shift+R", "F5", "Shift+F5"]);
|
||||
|
||||
function keyId(e: KeyboardEvent) {
|
||||
const key = e.code.startsWith("Key")
|
||||
? e.code.slice(3)
|
||||
: e.code === "BracketLeft"
|
||||
? "["
|
||||
: e.code === "BracketRight"
|
||||
? "]"
|
||||
: e.key;
|
||||
const key = letterOf(e) ?? (e.code === "BracketLeft" ? "[" : e.code === "BracketRight" ? "]" : e.key);
|
||||
return [e.ctrlKey && "Ctrl", e.altKey && "Alt", e.shiftKey && "Shift", e.metaKey && "Meta", key]
|
||||
.filter(Boolean)
|
||||
.join("+");
|
||||
|
||||
Reference in new issue
Заблокувати користувача