Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/commands/revealResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { VSCodeRevealOptions } from '../../api/src/index';
import { ext } from '../extensionVariables';
import { ResourceGroupsItem } from '../tree/ResourceGroupsItem';
import { ResourceTreeDataProviderBase } from '../tree/ResourceTreeDataProviderBase';
import { localize } from '../utils/localize';

export async function revealResource(context: IActionContext, resourceId: string, options?: VSCodeRevealOptions): Promise<void> {
setTelemetryPropertiesForId(context, resourceId);
Expand All @@ -17,6 +18,8 @@ export async function revealResource(context: IActionContext, resourceId: string
const item: ResourceGroupsItem | undefined = await (ext.v2.api.resources.azureResourceTreeDataProvider as ResourceTreeDataProviderBase).findItemById(resourceId);
if (item) {
await ext.appResourceTreeView.reveal(item as unknown as AzExtTreeItem, options ?? { expand: false, focus: true, select: true });
} else {
void context.ui.showWarningMessage(localize('resourceNotFound', 'Resource with id "${0}" not found.', resourceId));
}
} catch (error) {
context.telemetry.properties.revealError = parseError(error).message;
Expand Down
5 changes: 2 additions & 3 deletions src/tree/BranchDataItemCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export class BranchDataItemCache {
return this.branchItemToResourceGroupsItemCache.get(branchItem);
}

getItemForBranchItemById(branchItem: ResourceModelBase): ResourceGroupsItem | undefined {
const id = this.getIdForBranchItem(branchItem);
getItemForBranchItemById(id: string | undefined): ResourceGroupsItem | undefined {
if (!id) {
return undefined;
}
Expand All @@ -39,7 +38,7 @@ export class BranchDataItemCache {
}

createOrGetItem<T extends BranchDataItemWrapper>(branchItem: ResourceModelBase, createItem: () => T): T {
const cachedItem = this.getItemForBranchItemById(branchItem) as T | undefined;
const cachedItem = this.getItemForBranchItemById(this.getIdForBranchItem(branchItem)) as T | undefined;
if (cachedItem) {
cachedItem.branchItem = branchItem;
this.addBranchItem(branchItem, cachedItem);
Expand Down
5 changes: 4 additions & 1 deletion src/tree/ResourceTreeDataProviderBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ export abstract class ResourceTreeDataProviderBase extends vscode.Disposable imp
}

async findItemById(id: string): Promise<ResourceGroupsItem | undefined> {
let element: ResourceGroupsItem | undefined = undefined;
let element: ResourceGroupsItem | undefined = this.itemCache.getItemForBranchItemById(id);
if (element) {
return element;
}

outerLoop: while (true) {
const children: ResourceGroupsItem[] | null | undefined = await this.getChildren(element);
Expand Down