Skip to content

Commit

Permalink
Merge pull request #20979 from michelkaporin/debug-launch
Browse files Browse the repository at this point in the history
Ability to select and launch debug configuration
  • Loading branch information
isidorn committed Feb 21, 2017
2 parents ca1deee + 7001051 commit 95b377f
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/vs/workbench/parts/debug/browser/debugActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { IPartService } from 'vs/workbench/services/part/common/partService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { TogglePanelAction } from 'vs/workbench/browser/panel';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';

export abstract class AbstractDebugAction extends Action {

Expand Down Expand Up @@ -210,6 +211,27 @@ export class RunAction extends StartAction {
}
}

export class SelectAndStartAction extends AbstractDebugAction {
static ID = 'workbench.action.debug.selectandstart';
static LABEL = nls.localize('selectAndStartDebugging', "Select and Start Debugging");

constructor(id: string, label: string,
@IDebugService debugService: IDebugService,
@IKeybindingService keybindingService: IKeybindingService,
@ICommandService commandService: ICommandService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IFileService fileService: IFileService,
@IQuickOpenService private quickOpenService: IQuickOpenService
) {
super(id, label, undefined, debugService, keybindingService);
this.quickOpenService = quickOpenService;
}

public run(): TPromise<any> {
return this.quickOpenService.show('debug ');
}
}

export class RestartAction extends AbstractDebugAction {
static ID = 'workbench.action.debug.restart';
static LABEL = nls.localize('restartDebug', "Restart");
Expand Down
77 changes: 77 additions & 0 deletions src/vs/workbench/parts/debug/browser/debugQuickOpen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import nls = require('vs/nls');
import Filters = require('vs/base/common/filters');
import { TPromise } from 'vs/base/common/winjs.base';
import Quickopen = require('vs/workbench/browser/quickopen');
import QuickOpen = require('vs/base/parts/quickopen/common/quickOpen');
import Model = require('vs/base/parts/quickopen/browser/quickOpenModel');
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { IDebugService } from 'vs/workbench/parts/debug/common/debug';
import * as errors from 'vs/base/common/errors';

class DebugEntry extends Model.QuickOpenEntry {

constructor(private debugService: IDebugService, private configurationName: string, highlights: Model.IHighlight[] = []) {
super(highlights);
}

public getLabel(): string {
return this.configurationName;
}

public getAriaLabel(): string {
return nls.localize('entryAriaLabel', "{0}, debug", this.getLabel());
}

public run(mode: QuickOpen.Mode, context: Model.IContext): boolean {
if (mode === QuickOpen.Mode.PREVIEW) {
return false;
}
// Run selected debug configuration
this.debugService.getViewModel().setSelectedConfigurationName(this.configurationName);
this.debugService.createProcess(this.configurationName).done(undefined, errors.onUnexpectedError);

return true;
}
}

export class QuickOpenHandler extends Quickopen.QuickOpenHandler {

constructor(
@IQuickOpenService private quickOpenService: IQuickOpenService,
@IDebugService private debugService: IDebugService
) {
super();
}

public getAriaLabel(): string {
return nls.localize('debugAriaLabel', "Type a name of a launch configuration to run.");
}

public getResults(input: string): TPromise<Model.QuickOpenModel> {
const configurationNames = this.debugService.getConfigurationManager().getConfigurationNames()
.map(config => ({ config: config, highlights: Filters.matchesContiguousSubString(input, config) }))
.filter(({ highlights }) => !!highlights)
.map(({ config, highlights }) => new DebugEntry(this.debugService, config, highlights));

return TPromise.as(new Model.QuickOpenModel(configurationNames));
}

public getAutoFocus(input: string): QuickOpen.IAutoFocus {
return {
autoFocusFirstEntry: !!input
};
}

public getEmptyLabel(searchString: string): string {
if (searchString.length > 0) {
return nls.localize('noConfigurationsMatching', "No debug configurations matching");
}

return nls.localize('noConfigurationsFound', "No debug configurations found. Please create a 'launch.json' file.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { DebugEditorModelManager } from 'vs/workbench/parts/debug/browser/debugEditorModelManager';
import {
StepOverAction, ClearReplAction, FocusReplAction, StepIntoAction, StepOutAction, StartAction, RestartAction, ContinueAction, StopAction, DisconnectAction, PauseAction, AddFunctionBreakpointAction,
ConfigureAction, DisableAllBreakpointsAction, EnableAllBreakpointsAction, RemoveAllBreakpointsAction, RunAction, ReapplyBreakpointsAction
ConfigureAction, DisableAllBreakpointsAction, EnableAllBreakpointsAction, RemoveAllBreakpointsAction, RunAction, ReapplyBreakpointsAction, SelectAndStartAction
} from 'vs/workbench/parts/debug/browser/debugActions';
import { DebugActionsWidget } from 'vs/workbench/parts/debug/browser/debugActionsWidget';
import * as service from 'vs/workbench/parts/debug/electron-browser/debugService';
Expand All @@ -34,6 +34,7 @@ import 'vs/workbench/parts/debug/electron-browser/debugEditorContribution';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import * as debugCommands from 'vs/workbench/parts/debug/electron-browser/debugCommands';
import { IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';

class OpenDebugViewletAction extends ToggleViewletAction {
public static ID = VIEWLET_ID;
Expand Down Expand Up @@ -127,6 +128,17 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(EnableAllBreakpointsAc
registry.registerWorkbenchAction(new SyncActionDescriptor(DisableAllBreakpointsAction, DisableAllBreakpointsAction.ID, DisableAllBreakpointsAction.LABEL), 'Debug: Disable All Breakpoints', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(ClearReplAction, ClearReplAction.ID, ClearReplAction.LABEL), 'Debug: Clear Debug Console', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(FocusReplAction, FocusReplAction.ID, FocusReplAction.LABEL), 'Debug: Focus Debug Console', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(SelectAndStartAction, SelectAndStartAction.ID, SelectAndStartAction.LABEL), 'Debug: Launch Configuration', debugCategory);

// Register Quick Open
(<IQuickOpenRegistry>Registry.as(QuickOpenExtensions.Quickopen)).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
'vs/workbench/parts/debug/browser/debugQuickOpen',
'QuickOpenHandler',
'debug ',
nls.localize('debugCommands', "Debug XXX")
)
);

// register service
registerSingleton(IDebugService, service.DebugService);
Expand Down

0 comments on commit 95b377f

Please sign in to comment.