Skip to content

Commit 184c8d3

Browse files
committed
Avoids double view refresh
1 parent cdf3947 commit 184c8d3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/views/viewBase.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,14 @@ export abstract class ViewBase<
453453
return this.root;
454454
}
455455

456+
private _skipNextVisibilityChange: boolean = false;
457+
456458
getChildren(node?: ViewNode): ViewNode[] | Promise<ViewNode[]> {
457459
if (node != null) return node.getChildren();
458460

461+
// If we are already visible, then skip the next visibility change event otherwise we end up refreshing twice
462+
this._skipNextVisibilityChange = this.tree?.visible ?? false;
463+
459464
const root = this.ensureRoot();
460465
const children = root.getChildren();
461466
if (!this.initialized) {
@@ -527,7 +532,13 @@ export abstract class ViewBase<
527532
void this.container.usage.track(`${this.trackingFeature}:shown`).catch();
528533
}
529534

530-
this._onDidChangeVisibility.fire(e);
535+
const skip = this._skipNextVisibilityChange;
536+
this._skipNextVisibilityChange = false;
537+
538+
if (!skip || !e.visible) {
539+
this._onDidChangeVisibility.fire(e);
540+
}
541+
531542
if (e.visible) {
532543
this.notifySelections();
533544
}

0 commit comments

Comments
 (0)