Skip to content

Commit

Permalink
fix: Include user launch configurations in list
Browse files Browse the repository at this point in the history
Fixes #288

Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
  • Loading branch information
GordonSmith committed Nov 10, 2021
1 parent c095792 commit d7fd399
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/hpccplatform/launchConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,31 @@ export {
};

let g_launchConfigurations: { [name: string]: LaunchRequestArguments };
function gatherServers(wuf?: vscode.WorkspaceFolder) {
const eclLaunch = vscode.workspace.getConfiguration("launch", wuf.uri);
if (eclLaunch.has("configurations")) {
for (const launchConfig of eclLaunch.get<any[]>("configurations")!) {
if (launchConfig.type === "ecl" && launchConfig.name) {
g_launchConfigurations[launchConfig.name] = launchConfig;
}
function addLaunchConfiguration(configurations, source?: string) {
for (const launchConfig of configurations ?? []) {
if (launchConfig.type === "ecl" && launchConfig.name) {
const name = launchConfig.name + (source ? ` (${source})` : "");
g_launchConfigurations[name] = { ...launchConfig };
g_launchConfigurations[name].name = name;
}
}
}

function gatherServers(wuf?: vscode.WorkspaceFolder, wufCount: number = 0) {
const eclLaunch = vscode.workspace.getConfiguration("launch", wuf?.uri);
const configs = eclLaunch.inspect("configurations");
addLaunchConfiguration(configs.globalValue, "user settings");
addLaunchConfiguration(configs.workspaceFolderValue, wufCount > 1 ? wuf?.name : undefined);
addLaunchConfiguration(configs.workspaceValue, wufCount > 1 ? wuf?.name : undefined);
}

export function launchConfigurations(refresh = false): LaunchRequestArguments[] {
if (!g_launchConfigurations || refresh === true) {
g_launchConfigurations = {};

if (vscode.workspace.workspaceFolders) {
for (const wuf of vscode.workspace.workspaceFolders) {
gatherServers(wuf);
gatherServers(wuf, vscode.workspace.workspaceFolders.length);
}
} else {
gatherServers();
Expand Down

0 comments on commit d7fd399

Please sign in to comment.