Skip to content

Commit

Permalink
debug: some cleanup around getting launches
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Feb 13, 2018
1 parent 98101e1 commit 5a5c2a8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/parts/debug/browser/debugActionItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/parts/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ export interface IConfigurationManager {

getLaunches(): ILaunch[];

getLaunch(workspaceUri: uri): ILaunch | undefined;

/**
* Allows to register on change of selected debug configuration.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5a5c2a8

Please sign in to comment.