Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[debug] automatically create 'launch.json' #6490

Merged
merged 1 commit into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { DebugService } from '../common/debug-service';
import { DebugSchemaUpdater } from './debug-schema-updater';
import { DebugPreferences } from './debug-preferences';
import { TabBarToolbarContribution, TabBarToolbarRegistry, TabBarToolbarItem } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import { DebugSessionOptions } from './debug-session-options';

export namespace DebugMenus {
export const DEBUG = [...MAIN_MENU_BAR, '6_debug'];
Expand Down Expand Up @@ -512,10 +513,10 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
registerCommands(registry: CommandRegistry): void {
super.registerCommands(registry);
registry.registerCommand(DebugCommands.START, {
execute: () => this.start()
execute: (config?: DebugSessionOptions) => this.start(false, config)
});
registry.registerCommand(DebugCommands.START_NO_DEBUG, {
execute: () => this.start(true)
execute: (config?: DebugSessionOptions) => this.start(true, config)
});
registry.registerCommand(DebugCommands.STOP, {
execute: () => this.manager.currentSession && this.manager.currentSession.terminate(),
Expand Down Expand Up @@ -945,8 +946,13 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
return widget;
}

async start(noDebug?: boolean): Promise<void> {
let { current } = this.configurations;
async start(noDebug?: boolean, debugSessionOptions?: DebugSessionOptions): Promise<void> {
let current = debugSessionOptions ? debugSessionOptions : this.configurations.current;
// If no configurations are currently present, create the `launch.json` and prompt users to select the config.
if (!current) {
await this.configurations.addConfiguration();
return;
}
if (current) {
if (noDebug !== undefined) {
current = {
Expand Down
11 changes: 6 additions & 5 deletions packages/debug/src/browser/view/debug-configuration-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ import { DebugSessionManager } from '../debug-session-manager';
import { DebugAction } from './debug-action';
import { DebugViewModel } from './debug-view-model';
import { DebugSessionOptions } from '../debug-session-options';
import { DebugCommands } from '../debug-frontend-application-contribution';
import { CommandRegistry } from '@theia/core/lib/common';

@injectable()
export class DebugConfigurationWidget extends ReactWidget {

@inject(CommandRegistry)
protected readonly commandRegistry: CommandRegistry;

@inject(DebugViewModel)
protected readonly viewModel: DebugViewModel;

Expand Down Expand Up @@ -118,11 +123,7 @@ export class DebugConfigurationWidget extends ReactWidget {

protected readonly start = () => {
const configuration = this.manager.current;
if (configuration) {
this.sessionManager.start(configuration);
} else {
this.manager.addConfiguration();
}
this.commandRegistry.executeCommand(DebugCommands.START.id, configuration);
akosyakov marked this conversation as resolved.
Show resolved Hide resolved
}

protected readonly openConfiguration = () => this.manager.openConfiguration();
Expand Down