The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.
TypeScript code-editorcross-platformdapdatabase-clientdebuggerdesktop-appdeveloper-toolsgithttp-clientideintellijlsprusttauriterminal
feat(keymap): bind ⌘↓ to Jump to Source in the diff viewer on macOS (#2341)
ntbang0901d02aae2280e1
diff --git a/src/features/vcs/__tests__/diffToolbar.test.tsx b/src/features/vcs/__tests__/diffToolbar.test.tsxindex df2357084..719e6988a 100644--- a/src/features/vcs/__tests__/diffToolbar.test.tsx+++ b/src/features/vcs/__tests__/diffToolbar.test.tsx@@ -50,6 +50,9 @@ import { DiffEditorTab } from "../diff-editor-tab";import { diffInput, withChain, type DiffData } from "../diffInput";import { useToolWindowLayout } from "@/workbench/toolwindows/store";import { useProject } from "@/platform/project";+import { applyKeymapSettings, installKeyboardDispatcher, useKeymap } from "@/platform/keymap";+import { setContext } from "@/platform/context";+import { registerCompareActions } from "../compare";/** Git Log opens a commit's file: both sides are revisions. */const input = {@@ -456,6 +459,44 @@ describe("Jump to Source of a revision diff", () => {render(<DiffEditor input={input} />);expect(await jumpFrom(0, 2)).toEqual(["/p/a.ts", { selection: { line: 5, col: 1 }, focus: true }]);});++ it("jumps on ⌘↓ in the IntelliJ macOS keymap only while a diff pane has focus", async () => {+ setUp();+ const keymap = useKeymap.getState();+ applyKeymapSettings("intellij-macos", {});+ const unregister = registerCompareActions();+ const uninstall = installKeyboardDispatcher(window);+ const cmdDown = (target: EventTarget) => {+ const e = new KeyboardEvent("keydown", {+ key: "ArrowDown",+ code: "ArrowDown",+ metaKey: true,+ bubbles: true,+ cancelable: true,+ });+ target.dispatchEvent(e);+ return e;+ };+ try {+ render(<DiffEditor input={input} />);+ const v = await pane(1);+ v.dispatch({ selection: { anchor: v.state.doc.line(3).from + 1 } });+ v.contentDOM.dispatchEvent(new FocusEvent("focus"));+ v.contentDOM.dispatchEvent(new FocusEvent("focusin", { bubbles: true }));+ expect(cmdDown(v.contentDOM).defaultPrevented).toBe(true);+ await waitFor(() => expect(openFile).toHaveBeenCalled());+ expect(openFile.mock.calls[0]).toEqual(["/p/a.ts", { selection: { line: 3, col: 1 }, focus: true }]);++ setContext("diffEditorFocus", false);+ const plain = document.body.appendChild(document.createElement("div"));+ expect(cmdDown(plain).defaultPrevented).toBe(false);+ plain.remove();+ } finally {+ uninstall();+ unregister();+ useKeymap.setState(keymap);+ }+ });});describe("Unified Revert", () => {diff --git a/src/platform/keymaps/ideaParity.test.ts b/src/platform/keymaps/ideaParity.test.tsindex 939a86e0a..bb100d5be 100644--- a/src/platform/keymaps/ideaParity.test.ts+++ b/src/platform/keymaps/ideaParity.test.ts@@ -28,6 +28,8 @@ describe("IDEA keymap parity", () => {["code.quickDefinition", ["Alt+Space", "Meta+Y"], ["Ctrl+Shift+I"]],["editor.copyPathReference", ["Meta+Shift+C"], ["Ctrl+Shift+C"]],["project.open", ["F4", "Meta+Down"], ["F4"]],+ // Diff.OpenInEditor copies EditSource's shortcuts.+ ["diff.jumpToSource", ["F4", "Meta+Down"], ["F4"]],["project.delete", ["Delete", "Backspace", "Meta+Backspace"], ["Delete"]],["file.reloadFromDisk", ["Meta+Alt+Y"], ["Ctrl+Alt+Y"]],["project.reloadFromDisk", ["Meta+Alt+Y"], ["Ctrl+Alt+Y"]],diff --git a/src/platform/keymaps/intellij-macos.ts b/src/platform/keymaps/intellij-macos.tsindex cbb3f9b06..045ba6626 100644--- a/src/platform/keymaps/intellij-macos.ts+++ b/src/platform/keymaps/intellij-macos.ts@@ -323,10 +323,10 @@ export const intellijMacos: Record<string, string[]> = {"view.resetZoom": ["Ctrl+Alt+0"],"editor.increaseFontSize": ["Alt+Shift+."],"editor.decreaseFontSize": ["Alt+Shift+,"],- // Diff viewer (after Debug: F7 / ⇧F7 / F4 there win while a diff is focused)+ // Diff viewer (after Debug: F7 / ⇧F7 / F4 / ⌘↓ there win while a diff is focused)"diff.nextDifference": ["F7"],"diff.prevDifference": ["Shift+F7"],- "diff.jumpToSource": ["F4"],+ "diff.jumpToSource": ["F4", "Meta+Down"],"diff.applyLeftSide": ["Ctrl+Meta+Right"],"diff.applyRightSide": ["Ctrl+Meta+Left"],"diff.nextFile": ["Ctrl+Shift+Right"],