Файли
openidea/src/features/vcs/logPresentation.ts
T
Vadim LazukтаInf1mum 8fedc2efba fix(vcs): stop filtered logs from fanning one dashed lane per merge path (#2788)
A filtered log connects each visible commit to the nearest matching ancestor along every merge path, and in merge-heavy histories one row could collect dozens of dashed connections, each getting its own lane, so the graph column stretched the log horizontally. pruneFilteredEdges now drops a dashed connection whose target the commit's other connections already reach (shallowest first), so reachability is unchanged with one lane instead of one per hidden merge path. Real parents, collapsed fragments and unfiltered histories are untouched; parent/child navigation follows the same pruned graph.

Fixes #2670

Co-authored-by: Inf1mum <[email protected]>
2026-11-12 01:28:32 +08:00

40 рядки
1.5 KiB
TypeScript

import {
collapseLinear,
compactLanes,
computeGraph,
hideLongEdges,
linearizeMerges,
pruneFilteredEdges,
straightenLaneChanges,
} from "./graph";
import { commitKey, graphCommit, type RepoCommit } from "./multiRoot";
import type { LogOptions } from "./logOptions";
/** The same displayed adjacency drives painting, navigation and fragment actions. */
export function presentLogGraph(
all: readonly RepoCommit[],
options: LogOptions,
fragments: { expanded: ReadonlySet<string>; collapsed: ReadonlySet<string>; merges: ReadonlySet<string> },
keep: ReadonlySet<string>,
) {
const source = all.map(graphCommit);
const collapsed =
options.collapseLinear || fragments.collapsed.size
? collapseLinear(
source,
new Set([...keep, ...fragments.expanded]),
options.collapseLinear ? undefined : fragments.collapsed,
)
: null;
const expanded = fragments.merges.has("*")
? new Set(source.filter((c) => !fragments.merges.has(c.id)).map((c) => c.id))
: fragments.merges;
const linear = options.linearizeMerges ? linearizeMerges(collapsed?.graph ?? source, expanded) : null;
const graph = pruneFilteredEdges(linear?.graph ?? collapsed?.graph ?? source);
const byId = new Map(all.map((c) => [commitKey(c), c]));
const commits = graph.map((c) => byId.get(c.id)!);
const laid = computeGraph(graph).rows;
const rows = straightenLaneChanges(compactLanes(options.longEdges ? laid : hideLongEdges(laid)));
return { commits, graph, rows, linear, collapsed };
}