Files
openidea/src/features/vcs/diffNavigator.ts
T
l0ng-ai 22f409ae76 feat(diff): external diff tool and Show Diff for Lines (#3543)
- Settings › Tools › External Diff Tools: a program and its parameters
  (%1 the left file, %2 the right file, %3 the title). Diff viewers then
  offer Show Diff in External Tool (toolbar button and action). Saved
  files are passed as they are (saved first); revisions and texts go to
  temporary files named after the file. The program is always read from
  the global settings, never a project's, and runs on this machine.
- Show Diff for Lines (vcs.showDiffForLines): with the caret on changed
  lines in the editor, opens the file's diff at that line.
2026-11-15 22:18:58 +08:00

35 lines
1.4 KiB
TypeScript

/** The focused diff editor's chunk navigation, for actions that must not load the diff editor. */
import type { DiffViewerHost } from "./diffViewerProviders";
export interface DiffNavigator {
next(): void;
prev(): void;
jumpToSource(): void;
/** Apply the change at the caret from the left side to the right (`a`) or back (`b`). */
applyChange(source: "a" | "b"): boolean;
/** Open the next / previous file of the diff chain (changes of a commit or change list). */
file(dir: 1 | -1): void;
/** The viewer's settings as a popup menu (⇧⌘D). */
showSettings(): void;
/** IDEA's Select Opposite Diff Pane: focus the other side of a side-by-side diff; false when there is none. */
focusOpposite(): boolean;
/** IDEA's Close Diff Editor (Esc): closes the diff's editor tab; false when the diff isn't one. */
close(): boolean;
/** Swap Sides of a diff whose sides the user picked; false when it has none to swap. */
swapSides(): boolean;
/** Show Diff in External Tool; false when none is set up. */
showInExternalTool(): boolean;
/** The built panes, for diff viewer contributions' actions (null while loading). */
viewer?(): DiffViewerHost | null;
}
let focused: DiffNavigator | null = null;
export function focusedDiffNavigator(): DiffNavigator | null {
return focused;
}
export function setFocusedDiffNavigator(nav: DiffNavigator | null) {
focused = nav;
}