From 097b478d4972e64ceeca3669b0d615af9e3cc7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=A4der?= Date: Tue, 11 Feb 2025 13:22:32 +0100 Subject: [PATCH] Refresh root when change notification hast no items (#14868) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #14851 Contributed on behalf of STMicroelectronics Signed-off-by: Thomas Mäder --- .../plugin-ext/src/common/plugin-api-rpc.ts | 2 +- .../src/main/browser/view/tree-views-main.ts | 2 +- .../plugin-ext/src/plugin/tree/tree-views.ts | 30 +++++++++++-------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index 026ad4d5e05d3..d59308c209931 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -822,7 +822,7 @@ export interface TreeViewsMain { $registerTreeDataProvider(treeViewId: string, options?: RegisterTreeDataProviderOptions): void; $readDroppedFile(contentId: string): Promise; $unregisterTreeDataProvider(treeViewId: string): void; - $refresh(treeViewId: string, itemIds: string[]): Promise; + $refresh(treeViewId: string, itemIds?: string[]): Promise; $reveal(treeViewId: string, elementParentChain: string[], options: TreeViewRevealOptions): Promise; $setMessage(treeViewId: string, message: string): void; $setTitle(treeViewId: string, title: string): void; diff --git a/packages/plugin-ext/src/main/browser/view/tree-views-main.ts b/packages/plugin-ext/src/main/browser/view/tree-views-main.ts index 74993d2c14cfe..471a46c520a1f 100644 --- a/packages/plugin-ext/src/main/browser/view/tree-views-main.ts +++ b/packages/plugin-ext/src/main/browser/view/tree-views-main.ts @@ -110,7 +110,7 @@ export class TreeViewsMainImpl implements TreeViewsMain, Disposable { return BinaryBuffer.wrap(new Uint8Array(buffer)); } - async $refresh(treeViewId: string, items: string[]): Promise { + async $refresh(treeViewId: string, items?: string[]): Promise { const viewPanel = await this.viewRegistry.getView(treeViewId); const widget = viewPanel && viewPanel.widgets[0]; if (widget instanceof TreeViewWidget) { diff --git a/packages/plugin-ext/src/plugin/tree/tree-views.ts b/packages/plugin-ext/src/plugin/tree/tree-views.ts index 311872bf7664d..f5f94700ccd9b 100644 --- a/packages/plugin-ext/src/plugin/tree/tree-views.ts +++ b/packages/plugin-ext/src/plugin/tree/tree-views.ts @@ -253,21 +253,25 @@ class TreeViewExtImpl implements Disposable { }); this.toDispose.push(Disposable.create(() => this.proxy.$unregisterTreeDataProvider(treeViewId))); options.treeDataProvider.onDidChangeTreeData?.(elements => { - const ids = []; - elements = elements || []; - if (!Array.isArray(elements)) { - elements = [elements]; - } - const set = new Set(); - for (const element of elements) { - set.add(element); - } - for (const node of this.nodes.values()) { - if (node.value && set.has(node.value)) { - ids.push(node.id); + if (!elements) { + this.pendingRefresh = proxy.$refresh(treeViewId); + } else { + const ids = []; + elements = elements || []; + if (!Array.isArray(elements)) { + elements = [elements]; + } + const set = new Set(); + for (const element of elements) { + set.add(element); + } + for (const node of this.nodes.values()) { + if (node.value && set.has(node.value)) { + ids.push(node.id); + } } + this.pendingRefresh = proxy.$refresh(treeViewId, ids); } - this.pendingRefresh = proxy.$refresh(treeViewId, ids); }); }