From 091c25351bf75f334fc1b263d4c0715972cef02d Mon Sep 17 00:00:00 2001 From: arookieofc <2128194521@qq.com> Date: Fri, 30 Oct 2026 22:51:49 +0800 Subject: [PATCH] feat(keymap): bind Ctrl+Alt+click to Go to Implementation on Windows and Linux (#469) The Windows/Linux keymap only bound the Ctrl+Alt+B stroke to navigate.implementation, so the click gesture that #405 made remappable did nothing there. Adds Ctrl+Alt+Button1 alongside the existing macOS Meta+Alt+Button1 binding; other Alt-click gestures are unaffected because column mode and multi-caret need different modifiers. Closes #365 Co-authored-by: a-rookie-of-C-language <186315048+a-rookie-of-C-language@users.noreply.github.com> --- src/editor/lsp/navigationMouse.test.ts | 8 ++++++++ src/platform/keymaps/ideaParity.test.ts | 2 +- src/platform/keymaps/intellij-windows.ts | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/editor/lsp/navigationMouse.test.ts b/src/editor/lsp/navigationMouse.test.ts index 25dc94218..3940c61df 100644 --- a/src/editor/lsp/navigationMouse.test.ts +++ b/src/editor/lsp/navigationMouse.test.ts @@ -115,6 +115,14 @@ describe("mouse navigation", () => { expect(openFile).not.toHaveBeenCalled(); }); + it.each(["windows", "linux"] as const)("opens the implementation with Ctrl+Alt+click on %s", async (os) => { + usePlatform.setState({ os }); + useKeymap.setState({ preset: "intellij-windows", overrides: {} }); + click({ ctrlKey: true, altKey: true }); + await vi.waitFor(() => expect(openFile).toHaveBeenCalledOnce()); + expect(lspGoto).toHaveBeenCalledExactlyOnceWith(1, { line: 0, col: 9 }, "implementation"); + }); + it("does not navigate with Option+Command when the binding is removed", async () => { useKeymap.setState({ overrides: { "navigate.implementation": ["Meta+Alt+B"] } }); click({ metaKey: true, altKey: true }); diff --git a/src/platform/keymaps/ideaParity.test.ts b/src/platform/keymaps/ideaParity.test.ts index 839c98007..9cff980b6 100644 --- a/src/platform/keymaps/ideaParity.test.ts +++ b/src/platform/keymaps/ideaParity.test.ts @@ -36,7 +36,7 @@ describe("IDEA keymap parity", () => { ["window.previous", ["Meta+Alt+Shift+`"], ["Ctrl+Alt+["]], ["code.commentBlock", ["Meta+Alt+/", "Ctrl+Shift+/"], ["Ctrl+Shift+/"]], ["navigate.typeDeclaration", ["Meta+Shift+B", "Ctrl+Shift+B"], ["Ctrl+Shift+B"]], - ["navigate.implementation", ["Meta+Alt+B", "Meta+Alt+Button1"], ["Ctrl+Alt+B"]], + ["navigate.implementation", ["Meta+Alt+B", "Meta+Alt+Button1"], ["Ctrl+Alt+B", "Ctrl+Alt+Button1"]], ["find.next", ["Meta+G"], ["F3", "Ctrl+L"]], ["find.previous", ["Meta+Shift+G"], ["Shift+F3", "Ctrl+Shift+L"]], ["project.copy", ["Meta+C"], ["Ctrl+C", "Ctrl+Insert"]], diff --git a/src/platform/keymaps/intellij-windows.ts b/src/platform/keymaps/intellij-windows.ts index 3fb590e77..68627ea1d 100644 --- a/src/platform/keymaps/intellij-windows.ts +++ b/src/platform/keymaps/intellij-windows.ts @@ -20,7 +20,7 @@ export const intellijWindows: Record = { "navigate.forward": ["Ctrl+Alt+Right", "Button5"], "navigate.gotoLine": ["Ctrl+G"], "navigate.declaration": ["Ctrl+B"], - "navigate.implementation": ["Ctrl+Alt+B"], + "navigate.implementation": ["Ctrl+Alt+B", "Ctrl+Alt+Button1"], "navigate.typeDeclaration": ["Ctrl+Shift+B"], "navigate.fileStructure": ["Ctrl+F12"], "navigate.nextError": ["F2"],