Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 88c13d9884 fix(keymap): import an Emacs-based IDEA keymap on top of $default, not macOS
presetOf picked the macOS preset for any parent whose name contains "mac",
which includes "Emacs": a keymap derived from IDEA's Emacs keymap was
imported as based on macOS. The match is now on the word (Mac OS X, macOS),
and Emacs and its copies map to the $default preset they inherit in IDEA.

Refs #6896
2026-11-30 18:13:41 +08:00
2 змінених файлів з 20 додано та 2 видалено

No files matched your search

+16
Переглянути файл
@@ -49,6 +49,22 @@ describe("IntelliJ IDEA keymap import", () => {
expect(k.overrides).toEqual({});
});
it("bases a keymap derived from Emacs on $default, not macOS", () => {
for (const parent of ["Emacs", "Emacs copy"]) {
const k = parseIdeaKeymap(`<keymap name="E" parent="${parent}"></keymap>`);
expect(k.parent).toBe("intellij-windows");
}
for (const [parent, preset] of [
["Mac OS X", "intellij-macos"],
["macOS System Shortcuts", "intellij-macos"],
["Eclipse (Mac OS X)", "eclipse-macos"],
["VSCode (macOS)", "vscode-macos"],
["Default for KDE", "intellij-windows"],
]) {
expect(parseIdeaKeymap(`<keymap name="K" parent="${parent}"></keymap>`).parent).toBe(preset);
}
});
it("maps Duplicate Entire Lines, which has no shortcut in the presets", () => {
const k = parseIdeaKeymap(
`<keymap name="M" parent="Mac OS X 10.5+"><action id="EditorDuplicateLines"><keyboard-shortcut first-keystroke="shift meta D"/></action></keymap>`,
+4 -2
Переглянути файл
@@ -31,11 +31,13 @@ export interface ImportedIdeaKeymap {
/** IDEA's bundled keymap names (`<keymap name=…>`) → our presets. */
function presetOf(parent: string | null): string {
const p = parent ?? "";
const mac = /mac/i.test(p);
// "Mac OS X 10.5+", "Eclipse (Mac OS X)", "VSCode (macOS)"; not the "mac" inside "Emacs".
const mac = /\bmac(?: ?os)?\b/i.test(p);
if (/^eclipse/i.test(p)) return mac ? "eclipse-macos" : "eclipse-windows";
if (/^vs ?code/i.test(p)) return mac ? "vscode-macos" : "vscode-windows";
if (mac) return "intellij-macos";
if (p === "$default" || /^default for/i.test(p)) return "intellij-windows";
// IDEA's Emacs keymap (and copies of it) inherits $default.
if (p === "$default" || /^default for/i.test(p) || /^emacs\b/i.test(p)) return "intellij-windows";
return defaultPreset();
}