Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexweininger committed Jan 3, 2025
1 parent 6848740 commit 6320307
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/tree/BranchDataItemWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class BranchDataItemWrapper implements ResourceGroupsItem, Wrapper {
} else {
this.id = this.branchItem.id ?? this?.options?.defaultId ?? uuidv4();
}
this.id = this.options?.idPrefix ? `${this.options.idPrefix}/${this.id}` : this.id;
this.id = createBranchItemId(this.id, this.options?.idPrefix);
}

public readonly id: string;
Expand Down Expand Up @@ -123,10 +123,19 @@ export class BranchDataItemWrapper implements ResourceGroupsItem, Wrapper {
export type BranchDataItemFactory = (branchItem: ResourceModelBase, branchDataProvider: BranchDataProvider<ResourceBase, ResourceModelBase>, options?: BranchDataItemOptions) => BranchDataItemWrapper;

export function createBranchDataItemFactory(itemCache: BranchDataItemCache): BranchDataItemFactory {
return (branchItem, branchDataProvider, options) =>
itemCache.createOrGetItem(
return (branchItem, branchDataProvider, options) => {
return itemCache.createOrGetItem(
branchItem,
() => new BranchDataItemWrapper(branchItem, branchDataProvider, itemCache, options),
`${options?.idPrefix ?? ''}${branchItem.id}`,
createBranchItemId(branchItem.id, options?.idPrefix),
)
}
}

function createBranchItemId(id?: string, prefix?: string): string {
if (prefix?.endsWith('/') && id?.startsWith('/')) {
return `${prefix}${id.substring(1)}`;
} else {
return `${prefix ?? ''}${id}`;
}
}
2 changes: 1 addition & 1 deletion src/tree/ResourceTreeDataProviderBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,5 @@ export abstract class ResourceTreeDataProviderBase extends vscode.Disposable imp
}

function removePrefix(id: string): string {
return id.replace(/\/accounts\/.+\/tenants\/[^/]+\/+/i, '/')
return id.replace(/\/accounts\/.+\/tenants\/[^/]+\//i, '/')
}

0 comments on commit 6320307

Please sign in to comment.