Skip to content
This repository has been archived by the owner on Jul 17, 2019. It is now read-only.

Debug configuration resolved only when needed. #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,28 @@ export class RosDebugConfigProvider implements DebugConfigurationProvider {
}

async resolveDebugConfiguration(folder: WorkspaceFolder | undefined, config: DebugConfiguration, token?: CancellationToken) {
const packages = utils.getPackages();

const command = await window.showQuickPick(["roslaunch", "rosrun"], { placeHolder: "Launch command" });
const packageName = await window.showQuickPick(packages.then(Object.keys), { placeHolder: "Package" });

let target: string;

config.type = "ros";
if(!config.command){
config.command = await window.showQuickPick(["roslaunch", "rosrun"], { placeHolder: "Launch command" });
}
if(!config.package)
{
const packages = utils.getPackages();
config.package = await window.showQuickPick(packages.then(Object.keys), { placeHolder: "Package" });
}

if (packageName) {
if (!config.target) {
let basenames = (files: string[]) => files.map(file => basename(file));

if (command === "roslaunch") {
const launches = utils.findPackageLaunchFiles(packageName).then(basenames);
target = await window.showQuickPick(launches, { placeHolder: "Launch file" });
if (config.command === "roslaunch") {
const launches = utils.findPackageLaunchFiles(config.package).then(basenames);
config.target = await window.showQuickPick(launches, { placeHolder: "Launch file" });
} else {
const executables = utils.findPackageExecutables(packageName).then(basenames);
target = await window.showQuickPick(executables, { placeHolder: "Executable" });
const executables = utils.findPackageExecutables(config.package).then(basenames);
config.target = await window.showQuickPick(executables, { placeHolder: "Executable" });
}
} else {
target = await window.showInputBox({ placeHolder: "Target" });
}

config.type = "ros";
config.request = "launch";
config.command = command;
config.package = packageName;
config.target = target;
config.args = [];
config.debugSettings = "${command:debugSettings}";

return config;
Expand Down