Skip to content

Commit

Permalink
vscode-extension: resolve asconfigPath for multi-root workspaces wher…
Browse files Browse the repository at this point in the history
…e activated launch configuration is defined in the .code-workspace file

Previously, asconfigPath worked only for sub-projects in a single root workspace. Now, it detects if no workspaceFolder is specified, which means that it came from the .code-workspace file instead of launch.json.
  • Loading branch information
joshtynjala committed May 14, 2024
1 parent d7b57fe commit b8bb508
Showing 1 changed file with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,41 @@ export default class SWFDebugConfigurationProvider
throw new Error("SWF debugger launch failed. Java path not found.");
}

let asconfigPath = debugConfiguration.asconfigPath;

if (
workspaceFolder === undefined &&
vscode.workspace.workspaceFolders !== undefined
) {
// special case: launch configuration is defined in .code-workspace file
if (asconfigPath === undefined) {
vscode.window.showErrorMessage(
`Failed to debug SWF. Launch configurations in workspace files must specify asconfigPath field.`
);
return;
}
let asconfigPathParts = debugConfiguration.asconfigPath.split(/[\\\/]/g);
if (asconfigPathParts.length < 2) {
vscode.window.showErrorMessage(
`Failed to debug SWF. Launch configurations in workspace files must specify asconfigPath starting with workspace folder name.`
);
return;
}
let workspaceNameToFind = asconfigPathParts[0];
workspaceFolder = vscode.workspace.workspaceFolders.find(
(workspaceFolder) => workspaceFolder.name == workspaceNameToFind
);
if (!workspaceFolder) {
vscode.window.showErrorMessage(
`Failed to debug SWF. Workspace folder not found for file: ${asconfigPath}`
);
return;
}
asconfigPath = asconfigPathParts.slice(1).join(path.sep);
}
let asconfigJSON: any = null;
if (workspaceFolder !== undefined) {
var asconfigPath = debugConfiguration.asconfigPath
? debugConfiguration.asconfigPath
: FILE_NAME_ASCONFIG_JSON;
asconfigPath ??= FILE_NAME_ASCONFIG_JSON;
if (!path.isAbsolute(asconfigPath)) {
asconfigPath = path.resolve(workspaceFolder.uri.fsPath, asconfigPath);
}
Expand Down

0 comments on commit b8bb508

Please sign in to comment.