Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach shell should take focus #2421

Merged
merged 2 commits into from
Oct 20, 2020
Merged
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
2 changes: 1 addition & 1 deletion src/commands/containers/attachShellContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
2 changes: 1 addition & 1 deletion src/commands/images/runAzureCliImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ export async function runAzureCliImage(context: IActionContext): Promise<void> {
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 });
}
}
17 changes: 16 additions & 1 deletion src/utils/executeAsTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
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<void> {
let newEnv: NodeJS.ProcessEnv | undefined;
options = options ?? {};

Expand All @@ -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<void>((resolve, reject) => {
Expand Down