diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index a5f7c09068365..0817d995318b3 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -243,16 +243,9 @@ export class StepBackAction extends AbstractDebugAction { export class StopAction extends AbstractDebugAction { static ID = 'workbench.action.debug.stop'; static LABEL = nls.localize('stopDebug', "Stop"); - static DISCONNECT_LABEL = nls.localize('disconnectDebug', "Disconnect"); constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) { super(id, label, 'debug-action stop', debugService, keybindingService); - this.toDispose.push(this.debugService.onDidChangeState(() => { - const session = this.debugService.getActiveSession(); - if (session) { - this.updateLabel(session.configuration.isAttach ? StopAction.DISCONNECT_LABEL : StopAction.LABEL); - } - })); } public run(): TPromise { @@ -265,6 +258,25 @@ export class StopAction extends AbstractDebugAction { } } +export class DisconnectAction extends AbstractDebugAction { + static ID = 'workbench.action.debug.disconnect'; + static LABEL = nls.localize('disconnectDebug', "Disconnect"); + + constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) { + super(id, label, 'debug-action disconnect', debugService, keybindingService); + } + + public run(): TPromise { + const session = this.debugService.getActiveSession(); + return session ? session.disconnect(false, true) : TPromise.as(null); + } + + protected isEnabled(state: debug.State): boolean { + const session = this.debugService.getActiveSession(); + return super.isEnabled(state) && state !== debug.State.Inactive && session && session.configuration.isAttach; + } +} + export class ContinueAction extends AbstractDebugAction { static ID = 'workbench.action.debug.continue'; static LABEL = nls.localize('continueDebug', "Continue"); diff --git a/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts b/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts index cb574c0c3f478..a537711388514 100644 --- a/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts +++ b/src/vs/workbench/parts/debug/browser/debugActionsWidget.ts @@ -15,7 +15,7 @@ import actionbar = require('vs/base/browser/ui/actionbar/actionbar'); import constants = require('vs/workbench/common/constants'); import wbext = require('vs/workbench/common/contributions'); import debug = require('vs/workbench/parts/debug/common/debug'); -import dbgactions = require('vs/workbench/parts/debug/browser/debugActions'); +import {PauseAction, ContinueAction, StepBackAction, StopAction, DisconnectAction, StepOverAction, StepIntoAction, StepOutAction, RestartAction} from 'vs/workbench/parts/debug/browser/debugActions'; import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation'; import {IStorageService, StorageScope} from 'vs/platform/storage/common/storage'; import {IMessageService} from 'vs/platform/message/common/message'; @@ -34,9 +34,11 @@ export class DebugActionsWidget implements wbext.IWorkbenchContribution { private toDispose: lifecycle.IDisposable[]; private actionBar: actionbar.ActionBar; private actions: actions.IAction[]; - private pauseAction: dbgactions.PauseAction; - private continueAction: dbgactions.ContinueAction; - private stepBackAction: dbgactions.StepBackAction; + private pauseAction: PauseAction; + private continueAction: ContinueAction; + private stepBackAction: StepBackAction; + private stopAction: StopAction; + private disconnectAction: DisconnectAction; private isVisible: boolean; private isBuilt: boolean; @@ -159,29 +161,33 @@ export class DebugActionsWidget implements wbext.IWorkbenchContribution { private getActions(instantiationService: IInstantiationService, state: debug.State): actions.IAction[] { if (!this.actions) { - this.continueAction = instantiationService.createInstance(dbgactions.ContinueAction, dbgactions.ContinueAction.ID, dbgactions.ContinueAction.LABEL); - this.pauseAction = instantiationService.createInstance(dbgactions.PauseAction, dbgactions.PauseAction.ID, dbgactions.PauseAction.LABEL); + this.continueAction = instantiationService.createInstance(ContinueAction, ContinueAction.ID, ContinueAction.LABEL); + this.pauseAction = instantiationService.createInstance(PauseAction, PauseAction.ID, PauseAction.LABEL); + this.stopAction = instantiationService.createInstance(StopAction, StopAction.ID, StopAction.LABEL); + this.disconnectAction = instantiationService.createInstance(DisconnectAction, DisconnectAction.ID, DisconnectAction.LABEL); this.actions = [ this.continueAction, - instantiationService.createInstance(dbgactions.StepOverAction, dbgactions.StepOverAction.ID, dbgactions.StepOverAction.LABEL), - instantiationService.createInstance(dbgactions.StepIntoAction, dbgactions.StepIntoAction.ID, dbgactions.StepIntoAction.LABEL), - instantiationService.createInstance(dbgactions.StepOutAction, dbgactions.StepOutAction.ID, dbgactions.StepOutAction.LABEL), - instantiationService.createInstance(dbgactions.RestartAction, dbgactions.RestartAction.ID, dbgactions.RestartAction.LABEL), - instantiationService.createInstance(dbgactions.StopAction, dbgactions.StopAction.ID, dbgactions.StopAction.LABEL) + instantiationService.createInstance(StepOverAction, StepOverAction.ID, StepOverAction.LABEL), + instantiationService.createInstance(StepIntoAction, StepIntoAction.ID, StepIntoAction.LABEL), + instantiationService.createInstance(StepOutAction, StepOutAction.ID, StepOutAction.LABEL), + instantiationService.createInstance(RestartAction, RestartAction.ID, RestartAction.LABEL), + this.stopAction ]; this.actions.forEach(a => { this.toDispose.push(a); }); this.toDispose.push(this.pauseAction); - this.toDispose.push(this.continueAction); + this.toDispose.push(this.disconnectAction); } + this.actions[0] = state === debug.State.Running ? this.pauseAction : this.continueAction; + const session = this.debugService.getActiveSession(); + this.actions[5] = session && session.configuration.isAttach ? this.disconnectAction : this.stopAction; - const activeSession = this.debugService.getActiveSession(); - if (activeSession && activeSession.configuration.capabilities.supportsStepBack) { + if (session && session.configuration.capabilities.supportsStepBack) { if (!this.stepBackAction) { - this.stepBackAction = instantiationService.createInstance(dbgactions.StepBackAction, dbgactions.StepBackAction.ID, dbgactions.StepBackAction.LABEL); + this.stepBackAction = instantiationService.createInstance(StepBackAction, StepBackAction.ID, StepBackAction.LABEL); this.toDispose.push(this.stepBackAction); } diff --git a/src/vs/workbench/parts/debug/browser/media/debug.contribution.css b/src/vs/workbench/parts/debug/browser/media/debug.contribution.css index 030fd67b16eb3..84d85d10118b7 100644 --- a/src/vs/workbench/parts/debug/browser/media/debug.contribution.css +++ b/src/vs/workbench/parts/debug/browser/media/debug.contribution.css @@ -107,6 +107,10 @@ background: url('stop.svg') center center no-repeat; } +.monaco-workbench .debug-action.disconnect { + background: url('disconnect.svg') center center no-repeat; +} + .monaco-workbench .debug-action.clear-repl { background: url('clear-repl.svg') center center no-repeat; } @@ -137,7 +141,7 @@ cursor: -webkit-grabbing; } -.monaco-workbench .debug-actions-widget .monaco-action-bar .action-label { +.monaco-workbench .debug-actions-widget .monaco-action-bar .action-item > .action-label { width: 32px; height: 32px; margin-right: 0; @@ -323,6 +327,11 @@ background: url('stop-inverse.svg') center center no-repeat; } +.vs-dark .monaco-workbench .debug-action.disconnect, +.hc-black .monaco-workbench .debug-action.disconnect { + background: url('disconnect-inverse.svg') center center no-repeat; +} + .vs-dark .monaco-workbench .debug-action.clear-repl, .hc-black .monaco-workbench .debug-action.clear-repl { background: url('clear-repl-inverse.svg') center center no-repeat; diff --git a/src/vs/workbench/parts/debug/browser/media/disconnect-inverse.svg b/src/vs/workbench/parts/debug/browser/media/disconnect-inverse.svg new file mode 100644 index 0000000000000..606d91dd9cd42 --- /dev/null +++ b/src/vs/workbench/parts/debug/browser/media/disconnect-inverse.svg @@ -0,0 +1,12 @@ + + + + + Disconnect_16x_inverse + + + + + + + \ No newline at end of file diff --git a/src/vs/workbench/parts/debug/browser/media/disconnect.svg b/src/vs/workbench/parts/debug/browser/media/disconnect.svg new file mode 100644 index 0000000000000..b412a9b21af38 --- /dev/null +++ b/src/vs/workbench/parts/debug/browser/media/disconnect.svg @@ -0,0 +1,12 @@ + + + + + Disconnect_16x + + + + + + + \ No newline at end of file diff --git a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts index d225e3bb84915..148edcebc2143 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debug.contribution.ts @@ -25,7 +25,7 @@ import wbext = require('vs/workbench/common/contributions'); import * as debug from 'vs/workbench/parts/debug/common/debug'; import {DebugEditorModelManager} from 'vs/workbench/parts/debug/browser/debugEditorModelManager'; import {ToggleBreakpointAction, EditorConditionalBreakpointAction, ShowDebugHoverAction, SelectionToReplAction, RunToCursorAction, StepOverAction, - StepIntoAction, StepOutAction, StartAction, StepBackAction, RestartAction, ContinueAction, StopAction, PauseAction, AddFunctionBreakpointAction, + StepIntoAction, StepOutAction, StartAction, StepBackAction, RestartAction, ContinueAction, StopAction, DisconnectAction, PauseAction, AddFunctionBreakpointAction, ConfigureAction, ToggleReplAction, DisableAllBreakpointsAction, EnableAllBreakpointsAction, RemoveAllBreakpointsAction, RunAction, ReapplyBreakpointsAction} from 'vs/workbench/parts/debug/browser/debugActions'; import debugwidget = require('vs/workbench/parts/debug/browser/debugActionsWidget'); import service = require('vs/workbench/parts/debug/electron-browser/debugService'); @@ -102,6 +102,7 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(StepOutAction, StepOut registry.registerWorkbenchAction(new SyncActionDescriptor(StepBackAction, StepBackAction.ID, StepBackAction.LABEL, { primary: KeyMod.Shift | KeyCode.F10 }, debug.CONTEXT_IN_DEBUG_MODE), 'Debug: Step Back', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(RestartAction, RestartAction.ID, RestartAction.LABEL, { primary: KeyMod.Shift | KeyMod.CtrlCmd | KeyCode.F5 }, debug.CONTEXT_IN_DEBUG_MODE), 'Debug: Restart', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(StopAction, StopAction.ID, StopAction.LABEL, { primary: KeyMod.Shift | KeyCode.F5 }, debug.CONTEXT_IN_DEBUG_MODE), 'Debug: Stop', debugCategory); +registry.registerWorkbenchAction(new SyncActionDescriptor(DisconnectAction, DisconnectAction.ID, DisconnectAction.LABEL), 'Debug: Disconnect', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(ContinueAction, ContinueAction.ID, ContinueAction.LABEL, { primary: KeyCode.F5 }, debug.CONTEXT_IN_DEBUG_MODE), 'Debug: Continue', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(PauseAction, PauseAction.ID, PauseAction.LABEL), 'Debug: Pause', debugCategory); registry.registerWorkbenchAction(new SyncActionDescriptor(ConfigureAction, ConfigureAction.ID, ConfigureAction.LABEL), 'Debug: Open launch.json', debugCategory);