Skip to content

Commit

Permalink
fix: prevent race condition with refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsdev committed Oct 27, 2022
1 parent 5b8448f commit 421a9f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/api/src/localizedTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export class TypeInfoLocalizer {

constructor(private retrieveTypeInfo?: TypeInfoRetriever) {}

hasTypeInfo(info: TypeInfo): boolean {
return this.typeInfoMaps.has(info)
}

hasLocalizedTypeInfo(localizedInfo: LocalizedTypeInfo): boolean {
const info = this.localizedInfoOrigin.get(localizedInfo)
return !!(info && this.hasTypeInfo(info))
}

private localizeTypeInfo(
resolvedInfo: ResolvedArrayTypeInfo,
info?: TypeInfo,
Expand Down
6 changes: 5 additions & 1 deletion packages/typescript-explorer-vscode/src/view/typeTreeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ export class TypeTreeProvider implements vscode.TreeDataProvider<TypeTreeItem> {
this.createTypeNode(localizedTypeInfo, /* root */ undefined),
]
} else {
assert(this.typeInfoLocalizer, "typeInfoLocalizer should exist")
if (
!this.typeInfoLocalizer?.hasLocalizedTypeInfo(element.typeInfo)
) {
return []
}

const localizedChildren =
await this.typeInfoLocalizer.localizeChildren(element.typeInfo)
Expand Down

0 comments on commit 421a9f9

Please sign in to comment.