Skip to content

Commit

Permalink
Refresh root when change notification hast no items (#14868)
Browse files Browse the repository at this point in the history
Fixes #14851

Contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
  • Loading branch information
tsmaeder authored Feb 11, 2025
1 parent ccbc71a commit 984d95d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ export interface TreeViewsMain {
$registerTreeDataProvider(treeViewId: string, options?: RegisterTreeDataProviderOptions): void;
$readDroppedFile(contentId: string): Promise<BinaryBuffer>;
$unregisterTreeDataProvider(treeViewId: string): void;
$refresh(treeViewId: string, itemIds: string[]): Promise<void>;
$refresh(treeViewId: string, itemIds?: string[]): Promise<void>;
$reveal(treeViewId: string, elementParentChain: string[], options: TreeViewRevealOptions): Promise<any>;
$setMessage(treeViewId: string, message: string): void;
$setTitle(treeViewId: string, title: string): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class TreeViewsMainImpl implements TreeViewsMain, Disposable {
return BinaryBuffer.wrap(new Uint8Array(buffer));
}

async $refresh(treeViewId: string, items: string[]): Promise<void> {
async $refresh(treeViewId: string, items?: string[]): Promise<void> {
const viewPanel = await this.viewRegistry.getView(treeViewId);
const widget = viewPanel && viewPanel.widgets[0];
if (widget instanceof TreeViewWidget) {
Expand Down
30 changes: 17 additions & 13 deletions packages/plugin-ext/src/plugin/tree/tree-views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,21 +253,25 @@ class TreeViewExtImpl<T> 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<T>();
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<T>();
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);
});
}

Expand Down

0 comments on commit 984d95d

Please sign in to comment.