From ddd953df533055d353a3cbfcb61e34f8f1e84b47 Mon Sep 17 00:00:00 2001 From: "Brandon Waterloo [MSFT]" <36966225+bwateratmsft@users.noreply.github.com> Date: Wed, 11 Jan 2023 11:18:51 -0500 Subject: [PATCH] Scope config lookup to workspace folder --- src/debugging/DockerDebugConfigurationProvider.ts | 2 +- src/tasks/DockerRunTaskProvider.ts | 2 +- src/tasks/TaskHelper.ts | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/debugging/DockerDebugConfigurationProvider.ts b/src/debugging/DockerDebugConfigurationProvider.ts index c46acc459c..41b4441e0c 100644 --- a/src/debugging/DockerDebugConfigurationProvider.ts +++ b/src/debugging/DockerDebugConfigurationProvider.ts @@ -104,7 +104,7 @@ export class DockerDebugConfigurationProvider implements DebugConfigurationProvi } private async resolveDebugConfigurationInternal(context: DockerDebugContext, originalConfiguration: DockerDebugConfiguration): Promise { - 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); diff --git a/src/tasks/DockerRunTaskProvider.ts b/src/tasks/DockerRunTaskProvider.ts index 7b1dc5fc61..0f9029c079 100644 --- a/src/tasks/DockerRunTaskProvider.ts +++ b/src/tasks/DockerRunTaskProvider.ts @@ -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); diff --git a/src/tasks/TaskHelper.ts b/src/tasks/TaskHelper.ts index 5f674a4a16..eca9bd67f7 100644 --- a/src/tasks/TaskHelper.ts +++ b/src/tasks/TaskHelper.ts @@ -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 { // 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); @@ -131,17 +131,17 @@ export async function addTask(newTask: DockerBuildTaskDefinition | DockerRunTask return true; } -export async function getAssociatedDockerRunTask(debugConfiguration: DockerDebugConfiguration): Promise { +export async function getAssociatedDockerRunTask(debugConfiguration: DockerDebugConfiguration, folder: WorkspaceFolder): Promise { // 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 { +export async function getAssociatedDockerBuildTask(runTask: DockerRunTask, folder: WorkspaceFolder): Promise { // 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