@@ -8,7 +8,8 @@ import type { AIGenerateChangelogChanges } from '../../plus/ai/aiProviderService
88import { configuration } from '../../system/-webview/configuration' ;
99import { debug } from '../../system/decorators/log' ;
1010import { map } from '../../system/iterable' ;
11- import { pauseOnCancelOrTimeout } from '../../system/promise' ;
11+ import type { Deferred } from '../../system/promise' ;
12+ import { defer , pauseOnCancelOrTimeout } from '../../system/promise' ;
1213import type { ViewsWithCommits } from '../viewBase' ;
1314import type { PageableViewNode } from './abstract/viewNode' ;
1415import { ContextValues , getViewNodeId , ViewNode } from './abstract/viewNode' ;
@@ -76,16 +77,15 @@ export class ResultsCommitsNode<View extends ViewsWithCommits = ViewsWithCommits
7677 return this . context . comparisonFiltered ;
7778 }
7879
79- // Stop trying to update the label, because VS Code can't handle it and throws id conflict errors
80- // private _onChildrenCompleted: Deferred<void> | undefined;
80+ private _onChildrenCompleted : Deferred < void > | undefined ;
8181
8282 async getChildren ( ) : Promise < ViewNode [ ] > {
83- // this._onChildrenCompleted?.cancel();
84- // this._onChildrenCompleted = defer<void>();
83+ this . _onChildrenCompleted ?. cancel ( ) ;
84+ this . _onChildrenCompleted = defer < void > ( ) ;
8585
8686 const { log } = await this . getCommitsQueryResults ( ) ;
8787 if ( ! log ?. commits . size ) {
88- // this._onChildrenCompleted?.fulfill();
88+ this . _onChildrenCompleted ?. fulfill ( ) ;
8989 return [ new MessageNode ( this . view , this , 'No results found' ) ] ;
9090 }
9191
@@ -154,7 +154,7 @@ export class ResultsCommitsNode<View extends ViewsWithCommits = ViewsWithCommits
154154 children . push ( new LoadMoreNode ( this . view , this , children [ children . length - 1 ] ) ) ;
155155 }
156156
157- // this._onChildrenCompleted?.fulfill();
157+ this . _onChildrenCompleted ?. fulfill ( ) ;
158158 return children ;
159159 }
160160
@@ -166,28 +166,27 @@ export class ResultsCommitsNode<View extends ViewsWithCommits = ViewsWithCommits
166166 label = this . _label ;
167167 state = TreeItemCollapsibleState . Collapsed ;
168168 } else {
169- // let log;
169+ let log ;
170170
171171 const result = await pauseOnCancelOrTimeout ( this . getCommitsQueryResults ( ) , undefined , 100 ) ;
172172 if ( ! result . paused ) {
173173 state = this . _options . expand ? TreeItemCollapsibleState . Expanded : TreeItemCollapsibleState . Collapsed ;
174174
175- // ({ label, log } = result.value);
176- //
177- // state = !log?.commits.size
178- // ? TreeItemCollapsibleState.None
179- // : this._options.expand //|| log.count === 1
180- // ? TreeItemCollapsibleState.Expanded
181- // : TreeItemCollapsibleState.Collapsed;
175+ ( { label, log } = result . value ) ;
176+
177+ state = ! log ?. commits . size
178+ ? TreeItemCollapsibleState . None
179+ : this . _options . expand //|| log.count === 1
180+ ? TreeItemCollapsibleState . Expanded
181+ : TreeItemCollapsibleState . Collapsed ;
182182 } else {
183- // Stop trying to update the label, because VS Code can't handle it and throws id conflict errors
184- // queueMicrotask(async () => {
185- // try {
186- // await this._onChildrenCompleted?.promise;
187- // void (await result.value);
188- // this.view.triggerNodeChange(this.parent);
189- // } catch {}
190- // });
183+ queueMicrotask ( async ( ) => {
184+ try {
185+ await this . _onChildrenCompleted ?. promise ;
186+ void ( await result . value ) ;
187+ this . view . triggerNodeChange ( this . parent ) ;
188+ } catch { }
189+ } ) ;
191190
192191 // Need to use Collapsed before we have results or the item won't show up in the view until the children are awaited
193192 // https://github.com/microsoft/vscode/issues/54806 & https://github.com/microsoft/vscode/issues/62214
@@ -225,8 +224,7 @@ export class ResultsCommitsNode<View extends ViewsWithCommits = ViewsWithCommits
225224 if ( this . _results . deferred ) {
226225 this . _results . deferred = false ;
227226
228- // Stop trying to update the label, because VS Code can't handle it and throws id conflict errors
229- // void this.parent.triggerChange(false);
227+ void this . parent . triggerChange ( false ) ;
230228 }
231229 }
232230
0 commit comments