+
{options.showRepository && useVcs.getState().roots.length > 1 && (
{tx("Repository")}
)}
@@ -49,6 +64,7 @@ export function ColumnHeaders({
subject={cid === SUBJECT_COLUMN.id}
ids={visibleIds}
options={options}
+ columns={columns}
drag={drag}
onMove={move}
onDragOver={(id, target, after) =>
@@ -69,6 +85,7 @@ function LogColumnHeader({
subject,
ids,
options,
+ columns,
drag,
onMove,
onDragOver,
@@ -78,6 +95,7 @@ function LogColumnHeader({
subject?: boolean;
ids: string[];
options: LogOptions;
+ columns: LogColumn[];
drag: ColumnDrag | null;
onMove(source: string, target: string | null, after: boolean): void;
onDragOver(id: string, target: string | null, after: boolean): void;
@@ -90,26 +108,16 @@ function LogColumnHeader({
element: HTMLElement;
pointerId: number;
} | null>(null);
- const resizeDrag = useRef<{
- x: number;
- width: number;
- element: HTMLElement;
- pointerId: number;
- releaseCursor: () => void;
- } | null>(null);
const cancel = useCallback(() => {
- const captures = [press.current, resizeDrag.current];
+ const capture = press.current;
press.current = null;
- resizeDrag.current?.releaseCursor();
- resizeDrag.current = null;
- for (const capture of captures)
- if (capture?.element.hasPointerCapture?.(capture.pointerId))
- capture.element.releasePointerCapture(capture.pointerId);
+ if (capture?.element.hasPointerCapture?.(capture.pointerId))
+ capture.element.releasePointerCapture(capture.pointerId);
onDragCancel();
}, [onDragCancel]);
useEffect(() => {
const escape = (e: globalThis.KeyboardEvent) => {
- if (e.key !== "Escape" || (!press.current && !resizeDrag.current)) return;
+ if (e.key !== "Escape" || !press.current) return;
e.preventDefault();
e.stopPropagation();
cancel();
@@ -123,11 +131,15 @@ function LogColumnHeader({
};
}, [cancel]);
const width = options.columnWidths[column.id] ?? column.width ?? 120;
- const resize = (value: number) =>
- updateLogOptions({
- columnWidths: { ...logOptions().columnWidths, [column.id]: Math.max(40, Math.min(800, value)) },
- });
+ const resizeTarget: ResizeTarget = {
+ id: column.id,
+ width,
+ ...columnPrev(ids, column.id, options, columns),
+ // Commit is flex:1 — dragging its left divider only resizes the left neighbour.
+ leftOnly: subject || undefined,
+ };
const index = ids.indexOf(column.id);
+ const isFirst = index === 0;
const hitColumn = (x: number, y: number) => {
const el = document.elementFromPoint(x, y)?.closest?.("[data-log-column]");
if (!el || el.parentElement !== press.current?.element.parentElement) return null;
@@ -183,59 +195,32 @@ function LogColumnHeader({
disabled: index === ids.length - 1,
run: () => onMove(column.id, ids[index + 1] ?? null, true),
},
- ...(subject ? [] : [{ label: "Reset Width", run: () => resize(column.width ?? 120) }]),
+ ...(subject
+ ? []
+ : [
+ { label: "Reset Width", run: () => resetColumnWidth(column.id) },
+ { kind: "separator" as const },
+ {
+ label: tx("Hide Column"),
+ run: () => {
+ const key = HIDDEN_COLUMN_OPTION[column.id];
+ if (key) updateLogOptions({ [key]: false });
+ },
+ },
+ ]),
]);
}}
>
{tx(column.title)}
- {!subject && (
- {
- if (e.button !== 0) return;
- e.preventDefault();
- e.stopPropagation();
- resizeDrag.current = {
- x: e.clientX,
- width,
- element: e.currentTarget,
- pointerId: e.pointerId,
- releaseCursor: lockDragCursor("ew-resize"),
- };
- e.currentTarget.setPointerCapture(e.pointerId);
- }}
- onPointerMove={(e) => {
- if (resizeDrag.current && e.currentTarget.hasPointerCapture(e.pointerId))
- resize(resizeDrag.current.width + e.clientX - resizeDrag.current.x);
- }}
- onPointerUp={(e) => {
- resizeDrag.current?.releaseCursor();
- resizeDrag.current = null;
- if (e.currentTarget.hasPointerCapture(e.pointerId)) e.currentTarget.releasePointerCapture(e.pointerId);
- }}
- onPointerCancel={() => {
- resizeDrag.current?.releaseCursor();
- resizeDrag.current = null;
- }}
- onLostPointerCapture={() => {
- resizeDrag.current?.releaseCursor();
- resizeDrag.current = null;
- }}
- onKeyDown={(e) => {
- if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
- e.preventDefault();
- e.stopPropagation();
- if (e.altKey)
- onMove(column.id, ids[index + (e.key === "ArrowLeft" ? -1 : 1)] ?? null, e.key === "ArrowRight");
- else resize(width + (e.key === "ArrowLeft" ? -10 : 10));
- }}
+ {subject ? (
+ // Commit's left divider exists only in the header. It is decorative when
+ // Commit is the first column; otherwise it resizes the neighbour on its left.
+
+ ) : (
+ onMove(column.id, ids[index + delta] ?? null, delta === 1)}
/>
)}
diff --git a/src/features/vcs/log/ColumnResizeHandle.tsx b/src/features/vcs/log/ColumnResizeHandle.tsx
new file mode 100644
index 000000000..13f17a628
--- /dev/null
+++ b/src/features/vcs/log/ColumnResizeHandle.tsx
@@ -0,0 +1,49 @@
+import { tx } from "@/platform/i18n";
+import clsx from "clsx";
+import styles from "../GitLog.module.css";
+import { resizeColumnPair, useColumnResize, type ResizeTarget } from "./useColumnResize";
+
+/**
+ * Column divider on the column's left edge. A visible rule marks the grab target;
+ * hovering brightens it. Keyboard users get a focusable separator whose Left/Right
+ * arrows resize the adjacent pair (Alt+Left/Right reorders, header only).
+ *
+ * `disabled` renders the rule without any resize interaction — used for the
+ * first column's left border, which has no neighbour to give/take space.
+ */
+export function ColumnResizeHandle({
+ target,
+ title,
+ onReorder,
+ disabled,
+}: {
+ target: ResizeTarget;
+ title: string;
+ onReorder?: (delta: number) => void;
+ disabled?: boolean;
+}) {
+ const resize = useColumnResize(target);
+ return (
+ {
+ if (disabled || (e.key !== "ArrowLeft" && e.key !== "ArrowRight")) return;
+ e.preventDefault();
+ e.stopPropagation();
+ const delta = e.key === "ArrowLeft" ? -1 : 1;
+ if (e.altKey && onReorder) onReorder(delta);
+ // Handle is on the left edge: Left arrow widens this column.
+ // resizeColumnPair takes positive = widen, so invert the arrow delta.
+ else resizeColumnPair(target, -delta * 10);
+ }}
+ />
+ );
+}
diff --git a/src/features/vcs/log/CommitRow.tsx b/src/features/vcs/log/CommitRow.tsx
index aa585e067..fbdd87404 100644
--- a/src/features/vcs/log/CommitRow.tsx
+++ b/src/features/vcs/log/CommitRow.tsx
@@ -11,8 +11,10 @@ import { commitKey, commitRepo } from "../multiRoot";
import { repoName, useVcs } from "../store";
import { CommitMessage, RefLabels } from "./CommitMessage";
import { GraphCell } from "./GraphCell";
+import { RowResizeHandle } from "./RowResizeHandle";
import { commitMenu } from "./commitMenu";
import { SUBJECT_COLUMN, columnSequence, type LogColumn } from "./shared";
+import { columnPrev } from "./useColumnResize";
function CommitRowView({
id,
@@ -152,7 +154,12 @@ function CommitRowView({
id={id}
role="option"
aria-selected={selected}
- className={clsx(styles.row, onBranch && styles.currentBranch, selected && styles.selected)}
+ className={clsx(
+ styles.row,
+ onBranch && styles.currentBranch,
+ selected && styles.selected,
+ opts.showColumnDividers && styles.showDividers,
+ )}
style={{ top }}
onMouseDown={(e) => {
if (e.shiftKey) e.preventDefault(); // no text selection on range clicks
@@ -168,10 +175,11 @@ function CommitRowView({
{repoName(commitRepo(c)!)}
)}
- {columnSequence(opts.columnOrder, columns).map((cid) => {
+ {columnSequence(opts.columnOrder, columns).map((cid, _index, ids) => {
if (cid === SUBJECT_COLUMN.id) return subjectCell;
const column = columns.find((col) => col.id === cid);
if (!column) return null;
+ const width = opts.columnWidths[column.id] ?? column.width ?? 120;
return (
` : undefined}
>
{column.render(c)}
+
);
})}
diff --git a/src/features/vcs/log/FilterBar.tsx b/src/features/vcs/log/FilterBar.tsx
index d143317f7..fb5ab9de9 100644
--- a/src/features/vcs/log/FilterBar.tsx
+++ b/src/features/vcs/log/FilterBar.tsx
@@ -491,6 +491,7 @@ export function viewOptionsMenu(o: LogOptions): MenuItem[] {
toggle("GitHub Commit Checks", o, "showGitHubChecks"),
{ kind: "separator" },
toggle("Column Headers", o, "showColumnHeaders"),
+ toggle("Column Dividers", o, "showColumnDividers"),
],
},
{ kind: "separator" },
diff --git a/src/features/vcs/log/RowResizeHandle.tsx b/src/features/vcs/log/RowResizeHandle.tsx
new file mode 100644
index 000000000..acd3f856d
--- /dev/null
+++ b/src/features/vcs/log/RowResizeHandle.tsx
@@ -0,0 +1,9 @@
+import clsx from "clsx";
+import styles from "../GitLog.module.css";
+import { useColumnResize, type ResizeTarget } from "./useColumnResize";
+
+/** Full-height resize strip on a data-row cell (IDEA's column divider). */
+export function RowResizeHandle({ target }: { target: ResizeTarget }) {
+ const resize = useColumnResize(target);
+ return ;
+}
diff --git a/src/features/vcs/log/useColumnResize.ts b/src/features/vcs/log/useColumnResize.ts
new file mode 100644
index 000000000..fed1aa88a
--- /dev/null
+++ b/src/features/vcs/log/useColumnResize.ts
@@ -0,0 +1,144 @@
+import { lockDragCursor } from "@/ui";
+import {
+ useCallback,
+ useEffect,
+ useRef,
+ type MouseEvent as ReactMouseEvent,
+ type PointerEvent as ReactPointerEvent,
+} from "react";
+import { logOptions, type LogOptions } from "../logOptions";
+import { updateLogOptions } from "../logStore";
+import { SUBJECT_COLUMN, type LogColumn } from "./shared";
+
+const MIN_WIDTH = 40;
+const MAX_WIDTH = 800;
+const clamp = (value: number) => Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, value));
+
+export type ResizeTarget = {
+ id: string;
+ width: number;
+ /** Column to the left of this divider, or null when this is the first column. */
+ prevId: string | null;
+ prevWidth: number;
+ /** True for the flexible Commit column: only the left neighbour gets a stored width. */
+ leftOnly?: boolean;
+};
+
+/** Resolve the column immediately left of `id` in the visible order. */
+export function columnPrev(
+ ids: string[],
+ id: string,
+ options: LogOptions,
+ columns: LogColumn[],
+): { prevId: string | null; prevWidth: number } {
+ const index = ids.indexOf(id);
+ const prevId = index > 0 ? ids[index - 1] : null;
+ // The Commit column is flex:1 and absorbs space on its own — never store a width for it.
+ // (When *we are* the Commit column the caller handles the left neighbour via leftOnly,
+ // so this guard only applies to fixed columns whose left neighbour is Commit.)
+ if (!prevId || (prevId === SUBJECT_COLUMN.id && id !== SUBJECT_COLUMN.id)) return { prevId: null, prevWidth: 0 };
+ const prev = columns.find((c) => c.id === prevId);
+ // subject has no fixed width of its own; its "prevWidth" is unused in leftOnly mode.
+ return { prevId, prevWidth: options.columnWidths[prevId] ?? prev?.width ?? 120 };
+}
+
+/**
+ * Resize the divider between `id` (right) and `prevId` (left): only these two
+ * columns give/take space, so every other column stays put. When the left neighbour
+ * is the flexible Commit column, only the right column's width is stored (Commit
+ * absorbs the rest through flex:1).
+ */
+export function resizeColumnPair(target: ResizeTarget, delta: number) {
+ const { id, width, prevId, prevWidth, leftOnly } = target;
+ const widths = { ...logOptions().columnWidths };
+ if (prevId == null) {
+ // First column with no left neighbour (should be non-resizable at the UI layer).
+ widths[id] = clamp(width + delta);
+ } else if (leftOnly) {
+ // The Commit column is flex:1. The handle sits on the boundary (the left
+ // neighbour's right edge), so the divider follows the pointer: dragging right
+ // widens the left neighbour and shrinks Commit. `delta` is already -dx, so
+ // subtracting it makes the neighbour track dx exactly.
+ widths[prevId] = clamp(prevWidth - delta);
+ } else {
+ const left = clamp(prevWidth - delta);
+ const given = prevWidth - left; // what the left column actually gave up
+ widths[id] = clamp(width + given);
+ widths[prevId] = left;
+ }
+ updateLogOptions({ columnWidths: widths });
+}
+
+/** IDEA's double-click-on-divider behaviour: drop the custom width so the column fits its content again. */
+export function resetColumnWidth(id: string) {
+ const widths = { ...logOptions().columnWidths };
+ delete widths[id];
+ updateLogOptions({ columnWidths: widths });
+}
+
+type Drag = ResizeTarget & {
+ x: number;
+ element: HTMLElement;
+ pointerId: number;
+ releaseCursor: () => void;
+};
+
+/**
+ * Pointer-driven column resize with a full-height hit strip on the column's left
+ * edge. Dragging left widens the column (and narrows only its left neighbour);
+ * the divider follows the pointer 1:1.
+ */
+export function useColumnResize(target: ResizeTarget) {
+ const drag = useRef(null);
+ // Listeners are attached imperatively so `cancel` is defined before it is referenced.
+ const listeners = useRef<{ blur: () => void; escape: (e: KeyboardEvent) => void } | null>(null);
+ const cancel = useCallback(() => {
+ const d = drag.current;
+ if (!d) return;
+ d.releaseCursor();
+ drag.current = null;
+ if (d.element.hasPointerCapture?.(d.pointerId)) d.element.releasePointerCapture(d.pointerId);
+ if (listeners.current) {
+ window.removeEventListener("blur", listeners.current.blur);
+ window.removeEventListener("keydown", listeners.current.escape, true);
+ listeners.current = null;
+ }
+ }, []);
+ useEffect(() => () => cancel(), [cancel]);
+ return {
+ onPointerDown: (e: ReactPointerEvent) => {
+ if (e.button !== 0 || drag.current) return;
+ // Suppress the compatibility mousedown so a data-row strip doesn't select the row.
+ e.preventDefault();
+ e.stopPropagation();
+ const blur = () => cancel();
+ const escape = (ev: KeyboardEvent) => {
+ if (ev.key === "Escape") cancel();
+ };
+ drag.current = {
+ ...target,
+ x: e.clientX,
+ element: e.currentTarget,
+ pointerId: e.pointerId,
+ releaseCursor: lockDragCursor("ew-resize"),
+ };
+ listeners.current = { blur, escape };
+ e.currentTarget.setPointerCapture?.(e.pointerId);
+ window.addEventListener("blur", blur);
+ window.addEventListener("keydown", escape, true);
+ },
+ onPointerMove: (e: ReactPointerEvent) => {
+ const d = drag.current;
+ // Handle is on the left edge: drag left -> wider.
+ if (d && e.currentTarget.hasPointerCapture?.(e.pointerId)) resizeColumnPair(d, -(e.clientX - d.x));
+ },
+ onPointerUp: cancel,
+ onPointerCancel: cancel,
+ onLostPointerCapture: cancel,
+ onMouseDown: (e: ReactMouseEvent) => e.stopPropagation(),
+ onDoubleClick: (e: ReactMouseEvent) => {
+ e.stopPropagation();
+ resetColumnWidth(target.id);
+ },
+ };
+}
diff --git a/src/features/vcs/logOptions.ts b/src/features/vcs/logOptions.ts
index edb316c7f..80afc40c8 100644
--- a/src/features/vcs/logOptions.ts
+++ b/src/features/vcs/logOptions.ts
@@ -25,6 +25,8 @@ export interface LogOptions {
showGitHubChecks: boolean;
/** The row naming the columns, where they are resized and reordered. */
showColumnHeaders: boolean;
+ /** Draw a 1px divider on each column's left edge (off by default, like IDEA). */
+ showColumnDividers: boolean;
highlightMine: boolean;
highlightMerges: boolean;
highlightCurrentBranch: boolean;
@@ -63,6 +65,7 @@ export const DEFAULT_LOG_OPTIONS: LogOptions = {
showSignature: false,
showGitHubChecks: false,
showColumnHeaders: false,
+ showColumnDividers: false,
highlightMine: true,
highlightMerges: true,
highlightCurrentBranch: true,
diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json
index 2563d8d41..73b1c5589 100644
--- a/src/platform/locales/text/en.json
+++ b/src/platform/locales/text/en.json
@@ -2352,6 +2352,9 @@
"Search installed plugins": "Search installed plugins",
"Runs “conda create -n python=”: a new environment with only Python in it, in conda's envs directory; the new interpreter becomes the project interpreter.": "Runs “conda create -n python=”: a new environment with only Python in it, in conda's envs directory; the new interpreter becomes the project interpreter.",
"Java Agents": "Java Agents",
+ "Hide Column": "Hide Column",
+ "Column Dividers": "Column Dividers",
+ "{title} column border": "{title} column border",
"File at a Git revision (read-only).": "File at a Git revision (read-only).",
"Adjust colors for red-green vision deficiency is on, so this scheme shows its red-green colors.": "Adjust colors for red-green vision deficiency is on, so this scheme shows its red-green colors.",
"Appearance settings": "Appearance settings",
diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json
index 0ce7059e5..f1ab01f8f 100644
--- a/src/platform/locales/text/zh.json
+++ b/src/platform/locales/text/zh.json
@@ -8713,6 +8713,10 @@
"Run code inside the Java applications you start": "在你启动的 Java 应用中运行代码",
"Java agents of {list} were not added: they load only in local projects.": "未添加 {list} 的 Java 代理:Java 代理只加载到本地项目中。",
"Java agent": "Java 代理",
+ "Java Agents": "Java 代理",
+ "Hide Column": "隐藏该列",
+ "Column Dividers": "列分隔线",
+ "{title} column border": "{title}列边界",
"1 Pull Request": "1 个拉取请求",
"{count} Pull Requests": "{count} 个拉取请求",
"Issues": "议题",
@@ -8728,7 +8732,6 @@
"Session references and artifacts": "会话引用与制品",
"Copy Link": "复制链接",
"Add to Message": "添加到消息",
- "Java Agents": "Java 代理",
"File at a Git revision (read-only).": "Git 修订版中的文件(只读)。",
"Adjust colors for red-green vision deficiency is on, so this scheme shows its red-green colors.": "已开启「针对红绿色觉缺陷调整颜色」,此方案显示的是红绿色觉变体的颜色。",
"Appearance settings": "外观设置",