From 37c68c3a2d584788e8df1e0e4a89934153d8a4a0 Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 27 Mar 2019 14:53:36 +0100 Subject: [PATCH] debug: fix pause action also fixes #71198 --- .../contrib/debug/browser/debugCommands.ts | 14 +++++++++++++- .../debug/electron-browser/debug.contribution.ts | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/debugCommands.ts b/src/vs/workbench/contrib/debug/browser/debugCommands.ts index 36aca537e82..79d6cf9dd20 100644 --- a/src/vs/workbench/contrib/debug/browser/debugCommands.ts +++ b/src/vs/workbench/contrib/debug/browser/debugCommands.ts @@ -149,7 +149,19 @@ export function registerCommands(): void { primary: KeyCode.F6, when: CONTEXT_DEBUG_STATE.isEqualTo('running'), handler: (accessor: ServicesAccessor, _: string, thread: IThread | undefined) => { - getThreadAndRun(accessor, thread, thread => thread.pause()); + const debugService = accessor.get(IDebugService); + if (!(thread instanceof Thread)) { + thread = debugService.getViewModel().focusedThread; + if (!thread) { + const session = debugService.getViewModel().focusedSession; + const threads = session && session.getAllThreads(); + thread = threads && threads.length ? threads[0] : undefined; + } + } + + if (thread) { + thread.pause().then(undefined, onUnexpectedError); + } } }); diff --git a/src/vs/workbench/contrib/debug/electron-browser/debug.contribution.ts b/src/vs/workbench/contrib/debug/electron-browser/debug.contribution.ts index 29535c84316..5ed1edaca5a 100644 --- a/src/vs/workbench/contrib/debug/electron-browser/debug.contribution.ts +++ b/src/vs/workbench/contrib/debug/electron-browser/debug.contribution.ts @@ -276,7 +276,7 @@ const registerDebugToolBarItem = (id: string, title: string, icon: string, order }; registerDebugToolBarItem(CONTINUE_ID, continueLabel, 'continue', 10, CONTEXT_DEBUG_STATE.isEqualTo('stopped')); -registerDebugToolBarItem(PAUSE_ID, pauseLabel, 'pause', 10, CONTEXT_DEBUG_STATE.notEqualsTo('stopped'), CONTEXT_DEBUG_STATE.isEqualTo('running')); +registerDebugToolBarItem(PAUSE_ID, pauseLabel, 'pause', 10, CONTEXT_DEBUG_STATE.notEqualsTo('stopped')); registerDebugToolBarItem(STOP_ID, stopLabel, 'stop', 70, CONTEXT_FOCUSED_SESSION_IS_ATTACH.toNegated()); registerDebugToolBarItem(DISCONNECT_ID, disconnectLabel, 'disconnect', 70, CONTEXT_FOCUSED_SESSION_IS_ATTACH); registerDebugToolBarItem(STEP_OVER_ID, stepOverLabel, 'step-over', 20, undefined, CONTEXT_DEBUG_STATE.isEqualTo('stopped')); -- GitLab