Skip to content

Commit 770ba2b

Browse files
committed
Debugger: Add option to allow disconnect and stop/terminate UI elements
fixes microsoft#116731
1 parent 1988caa commit 770ba2b

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

src/vs/workbench/contrib/debug/browser/debug.contribution.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { CallStackView } from 'vs/workbench/contrib/debug/browser/callStackView'
1616
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
1717
import {
1818
IDebugService, VIEWLET_ID, DEBUG_PANEL_ID, CONTEXT_IN_DEBUG_MODE, INTERNAL_CONSOLE_OPTIONS_SCHEMA,
19-
CONTEXT_DEBUG_STATE, VARIABLES_VIEW_ID, CALLSTACK_VIEW_ID, WATCH_VIEW_ID, BREAKPOINTS_VIEW_ID, LOADED_SCRIPTS_VIEW_ID, CONTEXT_LOADED_SCRIPTS_SUPPORTED, CONTEXT_FOCUSED_SESSION_IS_ATTACH, CONTEXT_CALLSTACK_ITEM_TYPE, CONTEXT_RESTART_FRAME_SUPPORTED, CONTEXT_JUMP_TO_CURSOR_SUPPORTED, CONTEXT_DEBUG_UX, BREAKPOINT_EDITOR_CONTRIBUTION_ID, REPL_VIEW_ID, CONTEXT_BREAKPOINTS_EXIST, EDITOR_CONTRIBUTION_ID, CONTEXT_DEBUGGERS_AVAILABLE, CONTEXT_SET_VARIABLE_SUPPORTED, CONTEXT_BREAK_WHEN_VALUE_CHANGES_SUPPORTED, CONTEXT_VARIABLE_EVALUATE_NAME_PRESENT, getStateLabel, State, CONTEXT_WATCH_ITEM_TYPE, CONTEXT_STACK_FRAME_SUPPORTS_RESTART, CONTEXT_BREAK_WHEN_VALUE_IS_READ_SUPPORTED, CONTEXT_BREAK_WHEN_VALUE_IS_ACCESSED_SUPPORTED,
19+
CONTEXT_DEBUG_STATE, VARIABLES_VIEW_ID, CALLSTACK_VIEW_ID, WATCH_VIEW_ID, BREAKPOINTS_VIEW_ID, LOADED_SCRIPTS_VIEW_ID, CONTEXT_LOADED_SCRIPTS_SUPPORTED, CONTEXT_CALLSTACK_ITEM_TYPE, CONTEXT_RESTART_FRAME_SUPPORTED, CONTEXT_JUMP_TO_CURSOR_SUPPORTED, CONTEXT_DEBUG_UX, BREAKPOINT_EDITOR_CONTRIBUTION_ID, REPL_VIEW_ID, CONTEXT_BREAKPOINTS_EXIST, EDITOR_CONTRIBUTION_ID, CONTEXT_DEBUGGERS_AVAILABLE, CONTEXT_SET_VARIABLE_SUPPORTED, CONTEXT_BREAK_WHEN_VALUE_CHANGES_SUPPORTED, CONTEXT_VARIABLE_EVALUATE_NAME_PRESENT, getStateLabel, State, CONTEXT_WATCH_ITEM_TYPE, CONTEXT_STACK_FRAME_SUPPORTS_RESTART, CONTEXT_BREAK_WHEN_VALUE_IS_READ_SUPPORTED, CONTEXT_BREAK_WHEN_VALUE_IS_ACCESSED_SUPPORTED,
2020
} from 'vs/workbench/contrib/debug/common/debug';
2121
import { DebugToolBar } from 'vs/workbench/contrib/debug/browser/debugToolBar';
2222
import { DebugService } from 'vs/workbench/contrib/debug/browser/debugService';
@@ -97,8 +97,8 @@ registerDebugCommandPaletteItem(STEP_OVER_ID, STEP_OVER_LABEL, CONTEXT_IN_DEBUG_
9797
registerDebugCommandPaletteItem(STEP_INTO_ID, STEP_INTO_LABEL, CONTEXT_IN_DEBUG_MODE, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
9898
registerDebugCommandPaletteItem(STEP_OUT_ID, STEP_OUT_LABEL, CONTEXT_IN_DEBUG_MODE, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
9999
registerDebugCommandPaletteItem(PAUSE_ID, PAUSE_LABEL, CONTEXT_IN_DEBUG_MODE, CONTEXT_DEBUG_STATE.isEqualTo('running'));
100-
registerDebugCommandPaletteItem(DISCONNECT_ID, DISCONNECT_LABEL, CONTEXT_IN_DEBUG_MODE, CONTEXT_FOCUSED_SESSION_IS_ATTACH);
101-
registerDebugCommandPaletteItem(STOP_ID, STOP_LABEL, CONTEXT_IN_DEBUG_MODE, CONTEXT_FOCUSED_SESSION_IS_ATTACH.toNegated());
100+
registerDebugCommandPaletteItem(DISCONNECT_ID, DISCONNECT_LABEL, CONTEXT_IN_DEBUG_MODE);
101+
registerDebugCommandPaletteItem(STOP_ID, STOP_LABEL, CONTEXT_IN_DEBUG_MODE);
102102
registerDebugCommandPaletteItem(CONTINUE_ID, CONTINUE_LABEL, CONTEXT_IN_DEBUG_MODE, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
103103
registerDebugCommandPaletteItem(FOCUS_REPL_ID, nls.localize({ comment: ['Debug is a noun in this context, not a verb.'], key: 'debugFocusConsole' }, 'Focus on Debug Console View'));
104104
registerDebugCommandPaletteItem(JUMP_TO_CURSOR_ID, nls.localize('jumpToCursor', "Jump to Cursor"), CONTEXT_JUMP_TO_CURSOR_SUPPORTED);
@@ -123,8 +123,9 @@ const registerDebugViewMenuItem = (menuId: MenuId, id: string, title: string, or
123123
}
124124
});
125125
};
126-
registerDebugViewMenuItem(MenuId.DebugCallStackContext, RESTART_SESSION_ID, RESTART_LABEL, 10, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('session'));
127-
registerDebugViewMenuItem(MenuId.DebugCallStackContext, STOP_ID, STOP_LABEL, 20, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('session'));
126+
registerDebugViewMenuItem(MenuId.DebugCallStackContext, RESTART_SESSION_ID, RESTART_LABEL, 10, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('session'), undefined, '3_modification');
127+
registerDebugViewMenuItem(MenuId.DebugCallStackContext, DISCONNECT_ID, DISCONNECT_LABEL, 20, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('session'), undefined, '3_modification');
128+
registerDebugViewMenuItem(MenuId.DebugCallStackContext, STOP_ID, STOP_LABEL, 30, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('session'), undefined, '3_modification');
128129
registerDebugViewMenuItem(MenuId.DebugCallStackContext, PAUSE_ID, PAUSE_LABEL, 10, ContextKeyExpr.and(CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('thread'), CONTEXT_DEBUG_STATE.isEqualTo('running')));
129130
registerDebugViewMenuItem(MenuId.DebugCallStackContext, CONTINUE_ID, CONTINUE_LABEL, 10, ContextKeyExpr.and(CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('thread'), CONTEXT_DEBUG_STATE.isEqualTo('stopped')));
130131
registerDebugViewMenuItem(MenuId.DebugCallStackContext, STEP_OVER_ID, STEP_OVER_LABEL, 20, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('thread'), CONTEXT_DEBUG_STATE.isEqualTo('stopped'));

src/vs/workbench/contrib/debug/browser/debugCommands.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
278278
}
279279
});
280280

281-
async function stopHandler(accessor: ServicesAccessor, _: string, context: CallStackContext | unknown): Promise<void> {
281+
async function stopHandler(accessor: ServicesAccessor, _: string, context: CallStackContext | unknown, disconnect: boolean): Promise<void> {
282282
const debugService = accessor.get(IDebugService);
283283
let session: IDebugSession | undefined;
284284
if (isSessionContext(context)) {
@@ -294,23 +294,23 @@ async function stopHandler(accessor: ServicesAccessor, _: string, context: CallS
294294
session = session.parentSession;
295295
}
296296

297-
await debugService.stopSession(session);
297+
await debugService.stopSession(session, disconnect);
298298
}
299299

300300
KeybindingsRegistry.registerCommandAndKeybindingRule({
301301
id: DISCONNECT_ID,
302302
weight: KeybindingWeight.WorkbenchContrib,
303303
primary: KeyMod.Shift | KeyCode.F5,
304304
when: ContextKeyExpr.and(CONTEXT_FOCUSED_SESSION_IS_ATTACH, CONTEXT_IN_DEBUG_MODE),
305-
handler: stopHandler
305+
handler: (accessor, _, context) => stopHandler(accessor, _, context, true)
306306
});
307307

308308
KeybindingsRegistry.registerCommandAndKeybindingRule({
309309
id: STOP_ID,
310310
weight: KeybindingWeight.WorkbenchContrib,
311311
primary: KeyMod.Shift | KeyCode.F5,
312312
when: ContextKeyExpr.and(CONTEXT_FOCUSED_SESSION_IS_ATTACH.toNegated(), CONTEXT_IN_DEBUG_MODE),
313-
handler: stopHandler
313+
handler: (accessor, _, context) => stopHandler(accessor, _, context, false)
314314
});
315315

316316
CommandsRegistry.registerCommand({

src/vs/workbench/contrib/debug/browser/debugService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,9 @@ export class DebugService implements IDebugService {
736736
});
737737
}
738738

739-
async stopSession(session: IDebugSession | undefined): Promise<any> {
739+
async stopSession(session: IDebugSession | undefined, disconnect = false): Promise<any> {
740740
if (session) {
741-
return session.terminate();
741+
return disconnect ? session.disconnect() : session.terminate();
742742
}
743743

744744
const sessions = this.model.getSessions();
@@ -750,7 +750,7 @@ export class DebugService implements IDebugService {
750750
this.cancelTokens(undefined);
751751
}
752752

753-
return Promise.all(sessions.map(s => s.terminate()));
753+
return Promise.all(sessions.map(s => disconnect ? s.disconnect() : s.terminate()));
754754
}
755755

756756
private async substituteVariables(launch: ILaunch | undefined, config: IConfig): Promise<IConfig | undefined> {

src/vs/workbench/contrib/debug/browser/debugToolBar.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
2525
import { RunOnceScheduler } from 'vs/base/common/async';
2626
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
2727
import { createActionViewItem, createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
28-
import { IMenu, IMenuService, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
28+
import { ICommandAction, IMenu, IMenuService, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
2929
import { IContextKeyService, ContextKeyExpression, ContextKeyExpr, ContextKeyEqualsExpr } from 'vs/platform/contextkey/common/contextkey';
3030
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
3131
import * as icons from 'vs/workbench/contrib/debug/browser/debugIcons';
@@ -257,7 +257,7 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
257257

258258
// Debug toolbar
259259

260-
const registerDebugToolBarItem = (id: string, title: string, order: number, icon?: { light?: URI, dark?: URI } | ThemeIcon, when?: ContextKeyExpression, precondition?: ContextKeyExpression) => {
260+
const registerDebugToolBarItem = (id: string, title: string, order: number, icon?: { light?: URI, dark?: URI } | ThemeIcon, when?: ContextKeyExpression, precondition?: ContextKeyExpression, alt?: ICommandAction) => {
261261
MenuRegistry.appendMenuItem(MenuId.DebugToolBar, {
262262
group: 'navigation',
263263
when,
@@ -267,7 +267,8 @@ const registerDebugToolBarItem = (id: string, title: string, order: number, icon
267267
title,
268268
icon,
269269
precondition
270-
}
270+
},
271+
alt
271272
});
272273

273274
// Register actions in debug viewlet when toolbar is docked
@@ -286,8 +287,8 @@ const registerDebugToolBarItem = (id: string, title: string, order: number, icon
286287

287288
registerDebugToolBarItem(CONTINUE_ID, CONTINUE_LABEL, 10, icons.debugContinue, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
288289
registerDebugToolBarItem(PAUSE_ID, PAUSE_LABEL, 10, icons.debugPause, CONTEXT_DEBUG_STATE.notEqualsTo('stopped'), CONTEXT_DEBUG_STATE.isEqualTo('running'));
289-
registerDebugToolBarItem(STOP_ID, STOP_LABEL, 70, icons.debugStop, CONTEXT_FOCUSED_SESSION_IS_ATTACH.toNegated());
290-
registerDebugToolBarItem(DISCONNECT_ID, DISCONNECT_LABEL, 70, icons.debugDisconnect, CONTEXT_FOCUSED_SESSION_IS_ATTACH);
290+
registerDebugToolBarItem(STOP_ID, STOP_LABEL, 70, icons.debugStop, CONTEXT_FOCUSED_SESSION_IS_ATTACH.toNegated(), undefined, { id: DISCONNECT_ID, title: DISCONNECT_LABEL, icon: icons.debugDisconnect });
291+
registerDebugToolBarItem(DISCONNECT_ID, DISCONNECT_LABEL, 70, icons.debugDisconnect, CONTEXT_FOCUSED_SESSION_IS_ATTACH, undefined, { id: STOP_ID, title: STOP_LABEL, icon: icons.debugStop });
291292
registerDebugToolBarItem(STEP_OVER_ID, STEP_OVER_LABEL, 20, icons.debugStepOver, undefined, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
292293
registerDebugToolBarItem(STEP_INTO_ID, STEP_INTO_LABEL, 30, icons.debugStepInto, undefined, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
293294
registerDebugToolBarItem(STEP_OUT_ID, STEP_OUT_LABEL, 40, icons.debugStepOut, undefined, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));

src/vs/workbench/contrib/debug/common/debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ export interface IDebugService {
931931
/**
932932
* Stops the session. If no session is specified then all sessions are stopped.
933933
*/
934-
stopSession(session: IDebugSession | undefined): Promise<any>;
934+
stopSession(session: IDebugSession | undefined, disconnect?: boolean): Promise<any>;
935935

936936
/**
937937
* Makes unavailable all sources with the passed uri. Source will appear as grayed out in callstack view.

0 commit comments

Comments
 (0)