提交 5a5c2a8d 编写于 作者: I isidor

debug: some cleanup around getting launches

上级 98101e1a
......@@ -177,8 +177,8 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape {
}
public $startDebugging(_folderUri: uri | undefined, nameOrConfiguration: string | IConfig): TPromise<boolean> {
const folderUriString = _folderUri ? uri.revive(_folderUri).toString() : undefined;
const launch = folderUriString ? this.debugService.getConfigurationManager().getLaunches().filter(l => l.workspace && l.workspace.uri.toString() === folderUriString).pop() : undefined;
const folderUri = _folderUri ? uri.revive(_folderUri) : undefined;
const launch = this.debugService.getConfigurationManager().getLaunch(folderUri);
return this.debugService.startDebugging(launch, nameOrConfiguration).then(x => {
return true;
}, err => {
......
......@@ -156,7 +156,7 @@ export class StartDebugActionItem implements IActionItem {
const manager = this.debugService.getConfigurationManager();
const launches = manager.getLaunches();
const inWorkspace = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE;
manager.getLaunches().forEach(launch =>
launches.forEach(launch =>
launch.getConfigurationNames().forEach(name => {
if (name === manager.selectedConfiguration.name && launch === manager.selectedConfiguration.launch) {
this.selected = this.options.length;
......
......@@ -429,6 +429,8 @@ export interface IConfigurationManager {
getLaunches(): ILaunch[];
getLaunch(workspaceUri: uri): ILaunch | undefined;
/**
* Allows to register on change of selected debug configuration.
*/
......
......@@ -390,6 +390,14 @@ export class ConfigurationManager implements IConfigurationManager {
return this.launches;
}
public getLaunch(workspaceUri: uri): ILaunch {
if (!uri.isUri(workspaceUri)) {
return undefined;
}
return this.launches.filter(l => l.workspace && l.workspace.uri.toString() === workspaceUri.toString()).pop();
}
public get selectedConfiguration(): { launch: ILaunch, name: string } {
return {
launch: this.selectedLaunch,
......
......@@ -1061,7 +1061,7 @@ export class DebugService implements debug.IDebugService {
// Read the configuration again if a launch.json has been changed, if not just use the inmemory configuration
let config = process.configuration;
const launch = this.configurationManager.getLaunches().filter(l => l.workspace && process.session.root && l.workspace.uri.toString() === process.session.root.uri.toString()).pop();
const launch = process.session.root ? this.configurationManager.getLaunch(process.session.root.uri) : undefined;
if (this.launchJsonChanged && launch) {
this.launchJsonChanged = false;
config = launch.getConfiguration(process.configuration.name) || config;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册