Skip to content

Commit

Permalink
Scope config lookup to workspace folder (#3798)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwateratmsft authored Jan 19, 2023
1 parent aa14007 commit 1ee1c50
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/debugging/DockerDebugConfigurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class DockerDebugConfigurationProvider implements DebugConfigurationProvi
}

private async resolveDebugConfigurationInternal(context: DockerDebugContext, originalConfiguration: DockerDebugConfiguration): Promise<DockerDebugConfiguration | undefined> {
context.runDefinition = await getAssociatedDockerRunTask(originalConfiguration);
context.runDefinition = await getAssociatedDockerRunTask(originalConfiguration, context.folder);
context.actionContext.telemetry.properties.runTaskFound = context.runDefinition ? 'true' : 'false';

const helper = this.getHelper(context.platform);
Expand Down
2 changes: 1 addition & 1 deletion src/tasks/DockerRunTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class DockerRunTaskProvider extends DockerTaskProvider {

context.actionContext.telemetry.properties.containerOS = definition.dockerRun.os || 'Linux';

context.buildDefinition = await getAssociatedDockerBuildTask(task);
context.buildDefinition = await getAssociatedDockerBuildTask(task, context.folder);
context.actionContext.telemetry.properties.buildTaskFound = context.buildDefinition ? 'true' : 'false';

const helper = this.getHelper(context.platform);
Expand Down
12 changes: 6 additions & 6 deletions src/tasks/TaskHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ export function registerTaskProviders(ctx: ExtensionContext): void {
}

export function hasTask(taskLabel: string, folder: WorkspaceFolder): boolean {
const workspaceTasks = workspace.getConfiguration('tasks', folder.uri);
const workspaceTasks = workspace.getConfiguration('tasks', folder);
const allTasks = workspaceTasks && workspaceTasks.tasks as TaskDefinitionBase[] || [];
return allTasks.findIndex(t => t.label === taskLabel) > -1;
}

export async function addTask(newTask: DockerBuildTaskDefinition | DockerRunTaskDefinition, folder: WorkspaceFolder, overwrite?: boolean): Promise<boolean> {
// Using config API instead of tasks API means no wasted perf on re-resolving the tasks, and avoids confusion on resolved type !== true type
const workspaceTasks = workspace.getConfiguration('tasks', folder.uri);
const workspaceTasks = workspace.getConfiguration('tasks', folder);
const allTasks = workspaceTasks && workspaceTasks.tasks as TaskDefinitionBase[] || [];

const existingTaskIndex = allTasks.findIndex(t => t.label === newTask.label);
Expand All @@ -131,17 +131,17 @@ export async function addTask(newTask: DockerBuildTaskDefinition | DockerRunTask
return true;
}

export async function getAssociatedDockerRunTask(debugConfiguration: DockerDebugConfiguration): Promise<DockerRunTaskDefinition | undefined> {
export async function getAssociatedDockerRunTask(debugConfiguration: DockerDebugConfiguration, folder: WorkspaceFolder): Promise<DockerRunTaskDefinition | undefined> {
// Using config API instead of tasks API means no wasted perf on re-resolving the tasks (not just our tasks), and avoids confusion on resolved type !== true type
const workspaceTasks = workspace.getConfiguration('tasks');
const workspaceTasks = workspace.getConfiguration('tasks', folder);
const allTasks: TaskDefinitionBase[] = workspaceTasks && workspaceTasks.tasks as TaskDefinitionBase[] || [];

return await recursiveFindTaskByType(allTasks, 'docker-run', debugConfiguration) as DockerRunTaskDefinition;
}

export async function getAssociatedDockerBuildTask(runTask: DockerRunTask): Promise<DockerBuildTaskDefinition | undefined> {
export async function getAssociatedDockerBuildTask(runTask: DockerRunTask, folder: WorkspaceFolder): Promise<DockerBuildTaskDefinition | undefined> {
// Using config API instead of tasks API means no wasted perf on re-resolving the tasks (not just our tasks), and avoids confusion on resolved type !== true type
const workspaceTasks = workspace.getConfiguration('tasks');
const workspaceTasks = workspace.getConfiguration('tasks', folder);
const allTasks: TaskDefinitionBase[] = workspaceTasks && workspaceTasks.tasks as TaskDefinitionBase[] || [];

// Due to inconsistencies in the Task API, runTask does not have its dependsOn, so we need to re-find it by label
Expand Down

0 comments on commit 1ee1c50

Please sign in to comment.