diff --git a/src/commands/containers/attachShellContainer.ts b/src/commands/containers/attachShellContainer.ts index 1403cca40b..eda0d3428a 100644 --- a/src/commands/containers/attachShellContainer.ts +++ b/src/commands/containers/attachShellContainer.ts @@ -62,5 +62,5 @@ export async function attachShellContainer(context: IActionContext, node?: Conta shellCommand ); - await executeAsTask(context, terminalCommand, `Shell: ${node.containerName}`, { addDockerEnv: true, alwaysRunNew: true }); + await executeAsTask(context, terminalCommand, `Shell: ${node.containerName}`, { addDockerEnv: true, alwaysRunNew: true, focus: true }); } diff --git a/src/commands/images/runAzureCliImage.ts b/src/commands/images/runAzureCliImage.ts index 2c6dfcd764..56d3e36fa8 100644 --- a/src/commands/images/runAzureCliImage.ts +++ b/src/commands/images/runAzureCliImage.ts @@ -45,6 +45,6 @@ export async function runAzureCliImage(context: IActionContext): Promise { vol += ` -v ${workspaceFolder.uri.fsPath}:/workspace`; } - await executeAsTask(context, `docker run ${option} ${vol.trim()} -it --rm mcr.microsoft.com/azure-cli:latest`, 'Azure CLI', { addDockerEnv: true }); + await executeAsTask(context, `docker run ${option} ${vol.trim()} -it --rm mcr.microsoft.com/azure-cli:latest`, 'Azure CLI', { addDockerEnv: true, focus: true }); } } diff --git a/src/utils/executeAsTask.ts b/src/utils/executeAsTask.ts index 5ad1467c79..e37a6f4bf0 100644 --- a/src/utils/executeAsTask.ts +++ b/src/utils/executeAsTask.ts @@ -8,7 +8,16 @@ import * as vscode from 'vscode'; import { IActionContext } from 'vscode-azureextensionui'; import { addDockerSettingsToEnv } from './addDockerSettingsToEnv'; -export async function executeAsTask(context: IActionContext, command: string, name: string, options: { addDockerEnv?: boolean, workspaceFolder?: vscode.WorkspaceFolder, cwd?: string, alwaysRunNew?: boolean, rejectOnError?: boolean }): Promise { +interface ExecuteAsTaskOptions { + addDockerEnv?: boolean; + workspaceFolder?: vscode.WorkspaceFolder; + cwd?: string; + alwaysRunNew?: boolean; + rejectOnError?: boolean; + focus?: boolean; +} + +export async function executeAsTask(context: IActionContext, command: string, name: string, options: ExecuteAsTaskOptions): Promise { let newEnv: NodeJS.ProcessEnv | undefined; options = options ?? {}; @@ -34,6 +43,12 @@ export async function executeAsTask(context: IActionContext, command: string, na task.definition.idRandomizer = Math.random(); } + if (options.focus) { + task.presentationOptions = { + focus: true, + }; + } + const taskExecution = await vscode.tasks.executeTask(task); const taskEndPromise = new Promise((resolve, reject) => {