feat(vcs): diff preview in the Git window's Local Changes tab (#714)

The Local Changes tab of the Git tool window showed only the changes tree; a file's diff was visible only after opening a diff tab.

It now previews the selected file's working-tree diff beside the tree when the window is docked at the bottom and below it when docked on a side. The preview follows the selection (arrow keys included), shows a placeholder for no or multiple selection, and can be turned off with View Options › Show Diff Preview (persisted; the selection is kept when toggling).

The preview reuses the diff editor, whose toolbar did not fit a side-docked window: the editor is now a size container, the whitespace and highlighting pickers move to the settings menu below 640px and the separators go below 380px, buttons no longer shrink and the differences counter truncates.

Fixes #710.

Co-authored-by: a-rookie-of-C-language <[email protected]>
Цей коміт міститься в:
arookieofcтаa-rookie-of-C-language authored and GitHub committed 2026-11-03 10:18:39 +08:00
1 джерело 4f64ca3149
коміт 00e717d8fd
7 files changed
+226 -5

No files matched your search

+12
Переглянути файл
@@ -14,6 +14,8 @@ interface CommitState {
/** Commit Options › Run Git hooks. */
runHooks: boolean;
groupByDir: boolean;
/** Whether the Git window's Local Changes tab previews the selection's diff. */
diffPreview: boolean;
/** User overrides of the inclusion checkboxes (absolute path → state). */
checks: Map<string, CheckState>;
/** Changed blocks left out of the commit (absolute path → `hunkKeys`) of `hunks` files. */
@@ -42,6 +44,7 @@ export const useCommit = create<CommitState>(() => ({
author: "",
runHooks: true,
groupByDir: readBool("openidea.vcs.groupByDir", false),
diffPreview: readBool("openidea.vcs.diffPreview", true),
checks: new Map(),
excludedHunks: new Map(),
selection: [],
@@ -71,6 +74,15 @@ export function setGroupByDir(v: boolean) {
}
}
export function setDiffPreview(v: boolean) {
useCommit.setState({ diffPreview: v });
try {
localStorage.setItem("openidea.vcs.diffPreview", String(v));
} catch {
// ignore
}
}
const historyKey = () => `openidea.vcs.commitMessages:${useVcs.getState().root ?? ""}`;
const MAX_HISTORY = 20;