From a5dad7f6185e70eefbd4b4d1374377c397816281 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 20 Oct 2016 16:37:05 +0200 Subject: [PATCH] debug: restart and pause fix behavior when no focussed process --- src/vs/workbench/parts/debug/browser/debugActions.ts | 9 +++++++-- src/vs/workbench/parts/debug/common/debug.ts | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index c0685faee2f..baad2319ba6 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -152,7 +152,12 @@ export class RestartAction extends AbstractDebugAction { } public run(): TPromise { - const process = this.debugService.getViewModel().focusedProcess; + let process = this.debugService.getViewModel().focusedProcess; + if (!process) { + const processes = this.debugService.getModel().getProcesses(); + process = processes.length > 0 ? processes[0] : null; + } + return this.debugService.restartSession(process ? process.session : null); } @@ -326,7 +331,7 @@ export class PauseAction extends AbstractDebugAction { thread = this.debugService.getViewModel().focusedThread; } - return thread.pause(); + return thread ? thread.pause() : TPromise.as(null); } protected isEnabled(state: debug.State): boolean { diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index 8c1b7131640..c3f664c1aba 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -207,17 +207,17 @@ export interface IExceptionBreakpoint extends IEnablement { export interface IViewModel extends ITreeElement { /** - * Returns the focused debug process or null if there are no processes. + * Returns the focused debug process or null if no process is stopped. */ focusedProcess: IProcess; /** - * Returns the focused thread or null if there are no threads. + * Returns the focused thread or null if no thread is stopped. */ focusedThread: IThread; /** - * Returns the focused stack frame or null if there are no stack frames (debug inactive). + * Returns the focused stack frame or null if there are no stack frames. */ focusedStackFrame: IStackFrame; getSelectedExpression(): IExpression; -- GitLab