File tree Expand file tree Collapse file tree 1 file changed +22
-18
lines changed Expand file tree Collapse file tree 1 file changed +22
-18
lines changed Original file line number Diff line number Diff line change @@ -349,26 +349,30 @@ export abstract class ViewBase<
349349 ) : Promise < ViewNode | undefined > {
350350 const cc = Logger . getCorrelationContext ( ) ;
351351
352- // If we have no root (e.g. never been initialized) force it so the tree will load properly
353- if ( this . root == null ) {
354- await this . show ( ) ;
352+ async function find ( this : ViewBase < RootNode , ViewConfig > ) {
353+ try {
354+ const node = await this . findNodeCoreBFS (
355+ typeof predicate === 'string' ? n => n . id === predicate : predicate ,
356+ this . ensureRoot ( ) ,
357+ allowPaging ,
358+ canTraverse ,
359+ maxDepth ,
360+ token ,
361+ ) ;
362+
363+ return node ;
364+ } catch ( ex ) {
365+ Logger . error ( ex , cc ) ;
366+ return undefined ;
367+ }
355368 }
356369
357- try {
358- const node = await this . findNodeCoreBFS (
359- typeof predicate === 'string' ? n => n . id === predicate : predicate ,
360- this . ensureRoot ( ) ,
361- allowPaging ,
362- canTraverse ,
363- maxDepth ,
364- token ,
365- ) ;
366-
367- return node ;
368- } catch ( ex ) {
369- Logger . error ( ex , cc ) ;
370- return undefined ;
371- }
370+ if ( this . root != null ) return find . call ( this ) ;
371+
372+ // If we have no root (e.g. never been initialized) force it so the tree will load properly
373+ await this . show ( ) ;
374+ // Since we have to show the view, let the callstack unwind before we try to find the node
375+ return new Promise < ViewNode | undefined > ( resolve => setTimeout ( ( ) => resolve ( find . call ( this ) ) , 0 ) ) ;
372376 }
373377
374378 private async findNodeCoreBFS (
You can’t perform that action at this time.
0 commit comments