diff --git a/renovate.json b/renovate.json index 974dca3..6f62da5 100644 --- a/renovate.json +++ b/renovate.json @@ -6,4 +6,4 @@ "ignoreDeps": [ "@types/vscode" ] -} \ No newline at end of file +} diff --git a/shared/src/messages.ts b/shared/src/messages.ts index 70c04e7..1490dfc 100644 --- a/shared/src/messages.ts +++ b/shared/src/messages.ts @@ -145,7 +145,10 @@ export type SaveNames = z.infer export const childrenById = z.object({ message: z.literal('childrenById'), id: z.number(), + limit: z.number().optional().default(50), + offset: z.number().optional().default(0), children: z.array(zodTree).optional(), + total: z.number().optional(), }) export type ChildrenById = z.infer diff --git a/src/handleMessages.ts b/src/handleMessages.ts index 4f321c3..4d47565 100644 --- a/src/handleMessages.ts +++ b/src/handleMessages.ts @@ -43,7 +43,8 @@ export function handleMessage(panel: vscode.WebviewPanel, message: unknown): voi break } case 'childrenById': { - postMessage({ ...data, children: getChildrenById(data.id) }) // TODO: stream these + const { children, total } = getChildrenById(data.id, data.limit, data.offset) + postMessage({ ...data, children, total }) break } case 'typesById': { diff --git a/src/traceTree.ts b/src/traceTree.ts index 0618d33..dd526e7 100644 --- a/src/traceTree.ts +++ b/src/traceTree.ts @@ -133,14 +133,16 @@ export function showTree(startsWith: string, sourceFileName: string, position: n return nodes } -export function getChildrenById(id: number) { +export function getChildrenById(id: number, limit: number = 50, offset: number = 0) { const nodes = treeIdNodes.get(id)?.children ?? [] - const ret: typeof nodes = [] - nodes.forEach((node) => { + const total = nodes.length + const paginatedNodes = nodes.slice(offset, offset + limit) + const ret: typeof paginatedNodes = [] + paginatedNodes.forEach((node) => { treeIdNodes.set(node.id, node) ret.push({ ...node, children: [], types: [] }) }) - return ret + return { children: ret, total } } export function getTypesById(id: number) { diff --git a/ui/components/TreeNode.vue b/ui/components/TreeNode.vue index 997a094..9bddc8d 100644 --- a/ui/components/TreeNode.vue +++ b/ui/components/TreeNode.vue @@ -1,17 +1,29 @@