Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh root when change notification hast no items #14868

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading