| 66 | autoExpand?: boolean; |
| 67 | }) { |
| 68 | function dfs(node: INode, ancestors: INode[] = []) { |
| 69 | const [start, end] = |
| 70 | (node.payload?.lines as string)?.split(',').map((s) => +s) || []; |
| 71 | if (start >= 0 && start <= line && line < end) { |
| 72 | best = node; |
| 73 | bestAncestors = ancestors; |
| 74 | } |
| 75 | ancestors = [...ancestors, node]; |
| 76 | node.children?.forEach((child) => { |
| 77 | dfs(child, ancestors); |
| 78 | }); |
| 79 | } |
| 80 | let best: INode | undefined; |
| 81 | let bestAncestors: INode[] = []; |
| 82 | dfs((state.content.value as ITransformResult).root as INode); |