Skip to content

Commit

Permalink
Support configuration/tasks defined in workspaces (#1486)
Browse files Browse the repository at this point in the history
* Accommodate workspace-defined tasks/launch configs.

* Resolve linter warnings.
  • Loading branch information
philliphoff authored Dec 13, 2019
1 parent 1e933f6 commit 2375919
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/debugging/DockerDebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { CancellationToken, commands, debug, DebugConfiguration, DebugConfigurationProvider, MessageItem, ProviderResult, window, WorkspaceFolder } from 'vscode';
import { CancellationToken, commands, debug, DebugConfiguration, DebugConfigurationProvider, MessageItem, ProviderResult, window, workspace, WorkspaceFolder } from 'vscode';
import { callWithTelemetryAndErrorHandling, IActionContext } from 'vscode-azureextensionui';
import { DockerOrchestration } from '../constants';
import { getAssociatedDockerRunTask } from '../tasks/TaskHelper';
Expand Down Expand Up @@ -43,7 +43,11 @@ export class DockerDebugConfigurationProvider implements DebugConfigurationProvi
'docker-launch',
async (actionContext: IActionContext) => {
if (!folder) {
throw new Error('To debug with Docker you must first open a folder or workspace in VS Code.');
folder = workspace.workspaceFolders[0];

if (!folder) {
throw new Error('To debug with Docker you must first open a folder or workspace in VS Code.');
}
}

if (debugConfiguration.type === undefined) {
Expand Down
8 changes: 6 additions & 2 deletions src/tasks/DockerPseudoterminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See LICENSE.md in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { CancellationToken, CancellationTokenSource, Event, EventEmitter, Pseudoterminal, TerminalDimensions, WorkspaceFolder } from 'vscode';
import { CancellationToken, CancellationTokenSource, Event, EventEmitter, Pseudoterminal, TaskScope, TerminalDimensions, workspace, WorkspaceFolder } from 'vscode';
import { CommandLineBuilder } from '../utils/commandLineBuilder';
import { resolveVariables } from '../utils/resolveVariables';
import { spawnAsync } from '../utils/spawnAsync';
Expand All @@ -28,8 +28,12 @@ export class DockerPseudoterminal implements Pseudoterminal {
constructor(private readonly taskProvider: DockerTaskProvider, private readonly task: DockerBuildTask | DockerRunTask) { }

public open(initialDimensions: TerminalDimensions | undefined): void {
const folder = this.task.scope === TaskScope.Workspace
? workspace.workspaceFolders[0]
: this.task.scope as WorkspaceFolder;

const executeContext: DockerTaskExecutionContext = {
folder: this.task.scope as WorkspaceFolder,
folder,
cancellationToken: this.cts.token,
terminal: this,
}
Expand Down

0 comments on commit 2375919

Please sign in to comment.