Skip to content

Commit

Permalink
debug: seperate stop and disconnect actions
Browse files Browse the repository at this point in the history
fixes #9740
  • Loading branch information
isidorn committed Aug 23, 2016
1 parent 00c4091 commit 20b12fc
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 24 deletions.
26 changes: 19 additions & 7 deletions src/vs/workbench/parts/debug/browser/debugActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> {
Expand All @@ -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<any> {
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");
Expand Down
36 changes: 21 additions & 15 deletions src/vs/workbench/parts/debug/browser/debugActionsWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;

Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions src/vs/workbench/parts/debug/browser/media/disconnect-inverse.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/vs/workbench/parts/debug/browser/media/disconnect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 20b12fc

Please sign in to comment.