提交 83a7759f 编写于 作者: I isidor

debug: expose vscode.debugStart in API

fixes #3789
上级 083c36c6
......@@ -188,6 +188,15 @@ class ExtHostApiCommands {
{ name: 'newWindow', description: '(optional) Wether to open the folder in a new window or the same. Defaults to opening in the same window.', constraint: value => value === void 0 || typeof value === 'boolean' }
]
});
this._register('vscode.startDebug', (configurationName?: string) => {
return this._commands.executeCommand('_workbench.startDebug', configurationName);
}, {
description: 'Start a debugging session.',
args: [
{ name: 'configurationName', description: '(optional) Name of the debug configuration from \'launch.json\' to use.' }
]
});
}
// --- command impl
......
......@@ -40,14 +40,17 @@ export class SelectConfigActionItem extends BaseActionItem {
this.select.disabled = state !== State.Inactive;
}));
this.toDispose.push(configurationService.onDidUpdateConfiguration(e => {
this.setOptions().done(null, errors.onUnexpectedError);
this.setOptions(true).done(null, errors.onUnexpectedError);
}));
this.toDispose.push(this.debugService.getConfigurationManager().onDidConfigurationChange(name => {
this.setOptions(false).done(null, errors.onUnexpectedError);
}));
}
public render(container: HTMLElement): void {
dom.addClass(container, 'select-container');
container.appendChild(this.select);
this.setOptions().done(null, errors.onUnexpectedError);
this.setOptions(true).done(null, errors.onUnexpectedError);
}
public focus(): void {
......@@ -62,7 +65,7 @@ export class SelectConfigActionItem extends BaseActionItem {
}
}
private setOptions(): TPromise<any> {
private setOptions(changeDebugConfiguration: boolean): TPromise<any> {
let previousSelectedIndex = this.select.selectedIndex;
this.select.options.length = 0;
......@@ -91,7 +94,9 @@ export class SelectConfigActionItem extends BaseActionItem {
previousSelectedIndex = 0;
}
this.select.selectedIndex = previousSelectedIndex;
return this.actionRunner.run(this._action, configurations[previousSelectedIndex].name);
if (changeDebugConfiguration) {
return this.actionRunner.run(this._action, configurations[previousSelectedIndex].name);
}
}
});
}
......
......@@ -6,15 +6,18 @@
import 'vs/css!../browser/media/debug.contribution';
import 'vs/css!../browser/media/debugHover';
import nls = require('vs/nls');
import { TPromise } from 'vs/base/common/winjs.base';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import errors = require('vs/base/common/errors');
import editorcommon = require('vs/editor/common/editorCommon');
import { CommonEditorRegistry, ContextKey, EditorActionDescriptor } from 'vs/editor/common/editorCommonExtensions';
import { EditorBrowserRegistry } from 'vs/editor/browser/editorBrowserExtensions';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import platform = require('vs/platform/platform');
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { KbExpr, IKeybindings } from 'vs/platform/keybinding/common/keybindingService';
import { EditorBrowserRegistry } from 'vs/editor/browser/editorBrowserExtensions';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import wbaregistry = require('vs/workbench/common/actionRegistry');
import viewlet = require('vs/workbench/browser/viewlet');
import panel = require('vs/workbench/browser/panel');
......@@ -113,5 +116,17 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(dbgactions.AddFunction
registry.registerWorkbenchAction(new SyncActionDescriptor(dbgactions.ReapplyBreakpointsAction, dbgactions.ReapplyBreakpointsAction.ID, dbgactions.ReapplyBreakpointsAction.LABEL), 'Debug: Reapply All Breakpoints', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(dbgactions.RunAction, dbgactions.RunAction.ID, dbgactions.RunAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.F5 }, KbExpr.not(debug.CONTEXT_IN_DEBUG_MODE)), 'Debug: Start Without Debugging', debugCategory);
KeybindingsRegistry.registerCommandDesc({
id: '_workbench.startDebug',
weight: KeybindingsRegistry.WEIGHT.workbenchContrib(0),
handler(accessor: ServicesAccessor, configurationName: string) {
const debugService = accessor.get(debug.IDebugService);
(configurationName ? debugService.getConfigurationManager().setConfiguration(configurationName) : TPromise.as(null))
.done(() => debugService.createSession(false), errors.onUnexpectedError);
},
when: KbExpr.not(debug.CONTEXT_IN_DEBUG_MODE),
primary: undefined
});
// register service
registerSingleton(IDebugService, service.DebugService);
......@@ -27,15 +27,16 @@ import IDebugService = debug.IDebugService;
export class AbstractDebugAction extends actions.Action {
protected debugService: IDebugService;
private keybindingService: IKeybindingService;
protected toDispose: lifecycle.IDisposable[];
private keybinding: string;
constructor(id: string, label: string, cssClass: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
constructor(
id: string, label: string, cssClass: string,
@IDebugService protected debugService: IDebugService,
@IKeybindingService protected keybindingService: IKeybindingService
) {
super(id, label, cssClass, false);
this.debugService = debugService;
this.keybindingService = keybindingService;
this.toDispose = [];
this.toDispose.push(this.debugService.onDidChangeState((state) => this.updateEnablement(state)));
......@@ -119,7 +120,7 @@ export class StartDebugAction extends AbstractDebugAction {
}
public run(): TPromise<any> {
return this.debugService.createSession(false);
return this.keybindingService.executeCommand('_workbench.startDebug');
}
protected isEnabled(state: debug.State): boolean {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册