Файли
openidea/src/features/vcs/logSearch.ts
T
Shohruh Ismoilovтаshohruh-genius 9f2e6b570f feat(vcs): correct Git log graph projection and expand history views (#1076)
Git Log could lose commits when filtering by several paths, draw wrong
ancestry after filtering or collapsing rows, and open the wrong
repository in multi-root views. The graph is now projected over the full
commit DAG and laid out in Bek order, so filtered and collapsed views keep
the real ancestry; each log view keeps its own filters and requests.

Commit metadata, messages and path changes are kept in a persistent index
(by object id, in the IDE's cache directory) with seekable paging, and the
log gains parent-aware merge comparisons, a lazy revision browser,
read-only logs of repositories outside the project (opened with command
execution disabled), commit bookmarks, configurable built-in columns and
batched commit details. The adapted IntelliJ algorithms are attributed in
THIRD_PARTY_LICENSES.md.

Closes #872

Co-authored-by: shohruh-genius <[email protected]>
2026-11-05 02:31:32 +08:00

45 рядки
1.4 KiB
TypeScript

import type { Commit } from "@/bindings";
import type { LogOptions } from "./logOptions";
import { commitRepo } from "./multiRoot";
import { formatTime } from "./model";
export function visibleCommitText(c: Commit, options: LogOptions): string[] {
return [
c.summary,
c.refs.join(" "),
...(options.showRepository ? [commitRepo(c) ?? ""] : []),
...(options.showAuthor ? [c.author] : []),
...(options.showDate ? [formatTime(options.commitTimestamp ? (c.commitTimeMs ?? c.timeMs) : c.timeMs)] : []),
...(options.showHash ? [c.shortId] : []),
];
}
/** Case-insensitive word/subsequence matching; columns never form an artificial word. */
export function speedMatches(query: string, columns: readonly string[]): boolean {
return query
.toLocaleLowerCase()
.split(/\s+/)
.filter(Boolean)
.every((word) =>
columns.some((column) => {
let next = 0;
for (const c of column.toLocaleLowerCase()) if (c === word[next]) next++;
return next === word.length;
}),
);
}
export function nextSpeedMatch(
commits: readonly Commit[],
query: string,
options: LogOptions,
from: number,
direction = 1,
) {
for (let step = 1; step <= commits.length; step++) {
const i = (from + direction * step + commits.length * 2) % commits.length;
if (speedMatches(query, visibleCommitText(commits[i]!, options))) return i;
}
return -1;
}