feat(keymap): add Visual Studio and ReSharper keymap presets

Settings › Keymap gains Visual Studio and ReSharper presets (Windows/Linux
and macOS), generated from JetBrains' Visual Studio and ReSharper keymaps
with the same parent chain: Visual Studio builds on the IntelliJ preset of
the OS, ReSharper on Visual Studio. Where a preset gives a key to another
action, inherited bindings of context-free actions on that key are dropped
so the key does one thing.

IDEA_ACTIONS gains 64 standard IDEA action ids (Resume, StepOver, FindNext,
CompileDirty, SwitchHeaderSource, …), which also helps imported IDEA
keymaps and IdeaVim's :action, and imported keymaps based on Visual Studio,
ReSharper or NetBeans now pick that preset as their parent.
Цей коміт міститься в:
l0ng-ai committed 2026-12-05 02:13:27 +08:00
1 джерело 8f1d2afb0c
коміт f07b2fbcb6
8 files changed
+608 -2

No files matched your search

+67
Переглянути файл
@@ -0,0 +1,67 @@
import { describe, expect, it } from "vitest";
import { parseIdeaKeymap } from "../ideaKeymap";
import { PRESETS, PRESET_TITLES } from "../keymap";
import { resharperMacos } from "./resharper-macos";
import { resharperWindows } from "./resharper-windows";
import { visualStudioMacos } from "./visualstudio-macos";
import { visualStudioWindows } from "./visualstudio-windows";
/** Actions bound to `key` in `keymap`. */
const owners = (keymap: Record<string, string[]>, key: string) =>
Object.entries(keymap)
.filter(([, keys]) => keys.includes(key))
.map(([id]) => id)
.sort();
describe("Visual Studio and ReSharper keymaps", () => {
it("are available as presets", () => {
expect(PRESETS["visualstudio-windows"]).toBe(visualStudioWindows);
expect(PRESETS["resharper-windows"]).toBe(resharperWindows);
expect(PRESETS["visualstudio-macos"]).toBe(visualStudioMacos);
expect(PRESETS["resharper-macos"]).toBe(resharperMacos);
expect(PRESET_TITLES["visualstudio-windows"]).toBe("Visual Studio");
expect(PRESET_TITLES["resharper-windows"]).toBe("ReSharper");
});
it("use Visual Studio's debugger and navigation keys", () => {
expect(visualStudioWindows["debug.resume"]).toEqual(["F5"]);
expect(visualStudioWindows["debug.stepOver"]).toEqual(["F10"]);
expect(visualStudioWindows["debug.stepInto"]).toEqual(["F11"]);
expect(visualStudioWindows["build.buildProject"]).toEqual(["F7"]);
expect(visualStudioWindows["navigate.declaration"]).toEqual(["F12"]);
expect(visualStudioWindows["find.usages"]).toEqual(["Shift+F12"]);
// F9 toggles a breakpoint; Resume moved to F5 instead of keeping IDEA's F9.
expect(owners(visualStudioWindows, "F9")).toEqual(["debug.toggleBreakpoint"]);
});
it("layer ReSharper's keys over Visual Studio's", () => {
expect(visualStudioWindows["refactor.rename"]).toEqual(["Ctrl+R R", "Ctrl+R Ctrl+R"]);
expect(resharperWindows["refactor.rename"]).toEqual(["F2"]);
expect(resharperWindows["code.showIntentions"]).toContain("Alt+Enter");
expect(resharperWindows["navigate.declaration"]).toEqual(["Ctrl+B"]);
// Inherited from Visual Studio.
expect(resharperWindows["debug.stepOver"]).toEqual(["F10"]);
});
it("take a key from an inherited action that has no context of its own", () => {
// Ctrl+. shows context actions, so it no longer folds the selection.
expect(owners(visualStudioWindows, "Ctrl+.")).toEqual(["code.showIntentions"]);
// Ctrl+Shift+H is Replace in Files, not Shelve Silently.
expect(owners(resharperWindows, "Ctrl+Shift+H")).toEqual(["find.replaceInPath"]);
expect(owners(visualStudioMacos, "F10")).toEqual(["debug.stepOver"]);
});
it("keep the trackpad swipes for history on macOS", () => {
expect(visualStudioMacos["navigate.back"]).toContain("SwipeRight");
expect(resharperMacos["navigate.forward"]).toContain("SwipeLeft");
});
it("are the parents of imported IDEA keymaps based on them", () => {
const parent = (name: string) => parseIdeaKeymap(`<keymap name="Mine" parent="${name}"></keymap>`).parent;
expect(parent("Visual Studio")).toBe("visualstudio-windows");
expect(parent("Visual Studio OSX")).toBe("visualstudio-macos");
expect(parent("ReSharper")).toBe("resharper-windows");
expect(parent("ReSharper OSX")).toBe("resharper-macos");
expect(parent("NetBeans 6.5")).toBe("netbeans-windows");
});
});