feat(editor): Add an option to sync canvas with log view (#15391)

This commit is contained in:
Suguru Inoue
2025-05-22 17:25:58 +02:00
committed by GitHub
parent b1da30f493
commit 9938e63a66
19 changed files with 383 additions and 49 deletions

View File

@@ -488,13 +488,16 @@ function createLogTreeRec(context: LogTreeCreationContext) {
);
}
export function findLogEntryRec(id: string, entries: LogEntry[]): LogEntry | undefined {
export function findLogEntryRec(
isMatched: (entry: LogEntry) => boolean,
entries: LogEntry[],
): LogEntry | undefined {
for (const entry of entries) {
if (entry.id === id) {
if (isMatched(entry)) {
return entry;
}
const child = findLogEntryRec(id, entry.children);
const child = findLogEntryRec(isMatched, entry.children);
if (child) {
return child;
@@ -514,7 +517,7 @@ export function findSelectedLogEntry(
case 'none':
return undefined;
case 'selected': {
const entry = findLogEntryRec(selection.id, entries);
const entry = findLogEntryRec((e) => e.id === selection.id, entries);
if (entry) {
return entry;