From efac0c130df84cc86766fb6fdc4398d45c1a5eb0 Mon Sep 17 00:00:00 2001 From: Charles Wahome Date: Tue, 26 Nov 2024 18:05:37 +0300 Subject: [PATCH] Fix: show selection on tree after generation (#5833) --- .../src/commands/generate/generation-util.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/vscode/microsoft-kiota/src/commands/generate/generation-util.ts b/vscode/microsoft-kiota/src/commands/generate/generation-util.ts index b3b407a823..c372cb916f 100644 --- a/vscode/microsoft-kiota/src/commands/generate/generation-util.ts +++ b/vscode/microsoft-kiota/src/commands/generate/generation-util.ts @@ -1,16 +1,19 @@ import * as vscode from "vscode"; -import { treeViewId } from "../../constants"; +import { KIOTA_WORKSPACE_FILE, treeViewId } from "../../constants"; import { OpenApiTreeProvider } from "../../providers/openApiTreeProvider"; -import { getWorkspaceJsonPath, updateTreeViewIcons } from "../../util"; -import { loadWorkspaceFile } from "../../utilities/file"; +import { updateTreeViewIcons } from "../../util"; export async function displayGenerationResults(openApiTreeProvider: OpenApiTreeProvider, config: any) { const clientNameOrPluginName = config.clientClassName || config.pluginName; - openApiTreeProvider.refreshView(); - const workspaceJsonPath = getWorkspaceJsonPath(); - await loadWorkspaceFile({ fsPath: workspaceJsonPath }, openApiTreeProvider, clientNameOrPluginName); - await vscode.commands.executeCommand('kiota.workspace.refresh'); + const workspaceJson = vscode.workspace.textDocuments.find(doc => doc.fileName.endsWith(KIOTA_WORKSPACE_FILE)); + if (workspaceJson) { + const content = workspaceJson.getText(); + const workspace = JSON.parse(content); + const clientOrPluginObject = workspace.plugins[clientNameOrPluginName] || workspace.clients[clientNameOrPluginName]; + await openApiTreeProvider.loadEditPaths(clientNameOrPluginName, clientOrPluginObject); + } openApiTreeProvider.resetInitialState(); await updateTreeViewIcons(treeViewId, false, true); + await vscode.commands.executeCommand('kiota.workspace.refresh'); } \ No newline at end of file