Skip to content

Commit

Permalink
enable the debug view only if there are supported configurations
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <anton.kosyakov@typefox.io>
  • Loading branch information
akosyakov committed Nov 6, 2018
1 parent 3713217 commit c52e20f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
15 changes: 15 additions & 0 deletions packages/debug/src/browser/debug-configuration-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,21 @@ export class DebugConfigurationManager {
}
}

get supported(): Promise<IterableIterator<DebugSessionOptions>> {
return this.getSupported();
}
protected async getSupported(): Promise<IterableIterator<DebugSessionOptions>> {
const [, debugTypes] = await Promise.all([await this.initialized, this.debug.debugTypes()]);
return this.doGetSupported(new Set(debugTypes));
}
protected *doGetSupported(debugTypes: Set<string>): IterableIterator<DebugSessionOptions> {
for (const options of this.getAll()) {
if (debugTypes.has(options.configuration.type)) {
yield options;
}
}
}

protected _currentOptions: DebugSessionOptions | undefined;
get current(): DebugSessionOptions | undefined {
return this._currentOptions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
protected readonly manager: DebugSessionManager;

@inject(DebugConfigurationManager)
protected readonly confiugurations: DebugConfigurationManager;
protected readonly configurations: DebugConfigurationManager;

@inject(BreakpointManager)
protected readonly breakpointManager: BreakpointManager;
Expand All @@ -297,15 +297,21 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
widgetId: DebugWidget.ID,
widgetName: DebugWidget.LABEL,
defaultWidgetOptions: {
area: 'left'
area: 'left',
rank: 400
},
toggleCommandId: 'debug:toggle',
toggleKeybinding: 'ctrlcmd+shift+d'
});
}

async initializeLayout(): Promise<void> {
await this.openView();
((async () => {
const supported = await this.configurations.supported;
if (supported.next().value) {
await this.openView();
}
})());
}

protected firstSessionStart = true;
Expand Down Expand Up @@ -367,14 +373,12 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
url: launchSchemaUrl.toString()
});
});
await Promise.all([
this.confiugurations.load(),
this.breakpointManager.load()
]);
this.configurations.load();
await this.breakpointManager.load();
}

onStop(): void {
this.confiugurations.save();
this.configurations.save();
this.breakpointManager.save();
}

Expand Down Expand Up @@ -487,10 +491,10 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
});

registry.registerCommand(DebugCommands.OPEN_CONFIGURATIONS, {
execute: () => this.confiugurations.openConfiguration()
execute: () => this.configurations.openConfiguration()
});
registry.registerCommand(DebugCommands.ADD_CONFIGURATION, {
execute: () => this.confiugurations.addConfiguration()
execute: () => this.configurations.addConfiguration()
});

registry.registerCommand(DebugCommands.STEP_OVER, {
Expand Down Expand Up @@ -783,7 +787,7 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
}

async start(noDebug?: boolean): Promise<void> {
let { current } = this.confiugurations;
let { current } = this.configurations;
if (current) {
if (noDebug !== undefined) {
current = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export class SearchInWorkspaceFrontendContribution extends AbstractViewContribut
widgetId: SearchInWorkspaceWidget.ID,
widgetName: SearchInWorkspaceWidget.LABEL,
defaultWidgetOptions: {
area: 'left'
area: 'left',
rank: 300
},
toggleCommandId: SearchInWorkspaceCommands.TOGGLE_SIW_WIDGET.id
});
Expand Down

0 comments on commit c52e20f

Please sign in to comment.