From 6ec4b4c9c2eb494b5dc8781906bcbc22361b37ee Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 13 Sep 2023 12:24:06 -0400 Subject: [PATCH] Fixes wlecome view not showing when cleared --- src/views/searchAndCompareView.ts | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/views/searchAndCompareView.ts b/src/views/searchAndCompareView.ts index f7f4eae..4ba6e4f 100644 --- a/src/views/searchAndCompareView.ts +++ b/src/views/searchAndCompareView.ts @@ -52,11 +52,10 @@ export class SearchAndCompareViewNode extends ViewNode { } getChildren(): ViewNode[] { - if (this.children.length === 0) return []; + const children = this.children; + if (children.length === 0) return []; - this.view.message = undefined; - - return this.children.sort((a, b) => b.order - a.order); + return children.sort((a, b) => b.order - a.order); } getTreeItem(): TreeItem { @@ -68,9 +67,10 @@ export class SearchAndCompareViewNode extends ViewNode { } addOrReplace(results: CompareResultsNode | SearchResultsNode) { - if (this.children.includes(results)) return; + const children = this.children; + if (children.includes(results)) return; - this.children.push(results); + children.push(results); this.view.triggerNodeChange(); } @@ -99,12 +99,13 @@ export class SearchAndCompareViewNode extends ViewNode { node.dismiss(); } - if (this.children.length === 0) return; + const children = this.children; + if (children.length === 0) return; - const index = this.children.indexOf(node); + const index = children.indexOf(node); if (index === -1) return; - this.children.splice(index, 1); + children.splice(index, 1); this.view.triggerNodeChange(); } @@ -112,10 +113,11 @@ export class SearchAndCompareViewNode extends ViewNode { @gate() @debug() override async refresh(reset: boolean = false) { - if (this.children.length === 0) return; + const children = this.children; + if (children.length === 0) return; const promises: Promise[] = [ - ...filterMap(this.children, c => { + ...filterMap(children, c => { const result = c.refresh?.(reset); return isPromise(result) ? result : undefined; }), @@ -230,9 +232,10 @@ export class SearchAndCompareViewNode extends ViewNode { private removeComparePicker(silent: boolean = false) { void setContext('gitlens:views:canCompare', false); if (this.comparePicker != null) { - const index = this.children.indexOf(this.comparePicker); + const children = this.children; + const index = children.indexOf(this.comparePicker); if (index !== -1) { - this.children.splice(index, 1); + children.splice(index, 1); if (!silent) { void this.triggerChange(); }