diff --git a/src/vs/workbench/contrib/debug/browser/debugActionItems.ts b/src/vs/workbench/contrib/debug/browser/debugActionItems.ts index fe7b118c4c02b..e4f0afced3cbc 100644 --- a/src/vs/workbench/contrib/debug/browser/debugActionItems.ts +++ b/src/vs/workbench/contrib/debug/browser/debugActionItems.ts @@ -12,7 +12,7 @@ import { SelectBox, ISelectOptionItem } from 'vs/base/browser/ui/selectBox/selec import { SelectActionItem, IActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ICommandService } from 'vs/platform/commands/common/commands'; -import { IDebugService, IDebugSession } from 'vs/workbench/contrib/debug/common/debug'; +import { IDebugService, IDebugSession, IDebugConfiguration } from 'vs/workbench/contrib/debug/common/debug'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { attachSelectBoxStyler, attachStylerCallback } from 'vs/platform/theme/common/styler'; import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; @@ -192,9 +192,10 @@ export class StartDebugActionItem implements IActionItem { export class FocusSessionActionItem extends SelectActionItem { constructor( action: IAction, - @IDebugService protected debugService: IDebugService, + @IDebugService protected readonly debugService: IDebugService, @IThemeService themeService: IThemeService, @IContextViewService contextViewService: IContextViewService, + @IConfigurationService private readonly configurationService: IConfigurationService ) { super(null, action, [], -1, contextViewService, { ariaLabel: nls.localize('debugSession', 'Debug Session') }); @@ -234,6 +235,9 @@ export class FocusSessionActionItem extends SelectActionItem { } protected getSessions(): ReadonlyArray { - return this.debugService.getModel().getSessions(); + const hideSubSessions = this.configurationService.getValue('debug').hideSubSessions; + const sessions = this.debugService.getModel().getSessions(); + + return hideSubSessions ? sessions.filter(s => !s.parentSession) : sessions; } } diff --git a/src/vs/workbench/contrib/debug/browser/debugCommands.ts b/src/vs/workbench/contrib/debug/browser/debugCommands.ts index 79d6cf9dd20d6..44e5d5d108fac 100644 --- a/src/vs/workbench/contrib/debug/browser/debugCommands.ts +++ b/src/vs/workbench/contrib/debug/browser/debugCommands.ts @@ -9,7 +9,7 @@ import { List } from 'vs/base/browser/ui/list/listWidget'; import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { IListService } from 'vs/platform/list/browser/listService'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; -import { IDebugService, IEnablement, CONTEXT_BREAKPOINTS_FOCUSED, CONTEXT_WATCH_EXPRESSIONS_FOCUSED, CONTEXT_VARIABLES_FOCUSED, EDITOR_CONTRIBUTION_ID, IDebugEditorContribution, CONTEXT_IN_DEBUG_MODE, CONTEXT_EXPRESSION_SELECTED, CONTEXT_BREAKPOINT_SELECTED, IConfig, IStackFrame, IThread, IDebugSession, CONTEXT_DEBUG_STATE, REPL_ID } from 'vs/workbench/contrib/debug/common/debug'; +import { IDebugService, IEnablement, CONTEXT_BREAKPOINTS_FOCUSED, CONTEXT_WATCH_EXPRESSIONS_FOCUSED, CONTEXT_VARIABLES_FOCUSED, EDITOR_CONTRIBUTION_ID, IDebugEditorContribution, CONTEXT_IN_DEBUG_MODE, CONTEXT_EXPRESSION_SELECTED, CONTEXT_BREAKPOINT_SELECTED, IConfig, IStackFrame, IThread, IDebugSession, CONTEXT_DEBUG_STATE, REPL_ID, IDebugConfiguration } from 'vs/workbench/contrib/debug/common/debug'; import { Expression, Variable, Breakpoint, FunctionBreakpoint, Thread } from 'vs/workbench/contrib/debug/common/debugModel'; import { IExtensionsViewlet, VIEWLET_ID as EXTENSIONS_VIEWLET_ID } from 'vs/workbench/contrib/extensions/common/extensions'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; @@ -30,6 +30,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService import { IHistoryService } from 'vs/workbench/services/history/common/history'; import { startDebugging } from 'vs/workbench/contrib/debug/common/debugUtils'; import { IPanelService } from 'vs/workbench/services/panel/common/panelService'; +import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; export const ADD_CONFIGURATION_ID = 'debug.addConfiguration'; export const TOGGLE_INLINE_BREAKPOINT_ID = 'editor.debug.action.toggleInlineBreakpoint'; @@ -183,6 +184,12 @@ export function registerCommands(): void { const debugService = accessor.get(IDebugService); if (!session || !session.getId) { session = debugService.getViewModel().focusedSession; + const configurationService = accessor.get(IConfigurationService); + const hideSubSessions = configurationService.getValue('debug').hideSubSessions; + // Stop should be sent to the root parent session + while (hideSubSessions && session && session.parentSession) { + session = session.parentSession; + } } debugService.stopSession(session).then(undefined, onUnexpectedError); diff --git a/src/vs/workbench/contrib/debug/browser/debugToolBar.ts b/src/vs/workbench/contrib/debug/browser/debugToolBar.ts index facfeddcfb421..1932720ed590f 100644 --- a/src/vs/workbench/contrib/debug/browser/debugToolBar.ts +++ b/src/vs/workbench/contrib/debug/browser/debugToolBar.ts @@ -23,7 +23,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; import { registerColor, contrastBorder, widgetShadow } from 'vs/platform/theme/common/colorRegistry'; import { localize } from 'vs/nls'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; -import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView'; +import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { RunOnceScheduler } from 'vs/base/common/async'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -67,7 +67,6 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution { @IConfigurationService private readonly configurationService: IConfigurationService, @IThemeService themeService: IThemeService, @IKeybindingService private readonly keybindingService: IKeybindingService, - @IContextViewService contextViewService: IContextViewService, @IInstantiationService private readonly instantiationService: IInstantiationService, @IMenuService menuService: IMenuService, @IContextMenuService contextMenuService: IContextMenuService, @@ -89,7 +88,7 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution { orientation: ActionsOrientation.HORIZONTAL, actionItemProvider: (action: IAction) => { if (action.id === FocusSessionAction.ID) { - return new FocusSessionActionItem(action, this.debugService, this.themeService, contextViewService); + return this.instantiationService.createInstance(FocusSessionActionItem, action); } if (action instanceof MenuItemAction) { return new MenuItemActionItem(action, this.keybindingService, this.notificationService, contextMenuService); diff --git a/src/vs/workbench/contrib/debug/browser/debugViewlet.ts b/src/vs/workbench/contrib/debug/browser/debugViewlet.ts index 289b4dc7ca30e..7bb82f5bf93fd 100644 --- a/src/vs/workbench/contrib/debug/browser/debugViewlet.ts +++ b/src/vs/workbench/contrib/debug/browser/debugViewlet.ts @@ -136,7 +136,7 @@ export class DebugViewlet extends ViewContainerViewlet { return this.startDebugActionItem; } if (action.id === FocusSessionAction.ID) { - return new FocusSessionActionItem(action, this.debugService, this.themeService, this.contextViewService); + return new FocusSessionActionItem(action, this.debugService, this.themeService, this.contextViewService, this.configurationService); } if (action instanceof MenuItemAction) { return new MenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService); diff --git a/src/vs/workbench/contrib/debug/common/debug.ts b/src/vs/workbench/contrib/debug/common/debug.ts index 30b3ef44795fd..660eae6c7f9cf 100644 --- a/src/vs/workbench/contrib/debug/common/debug.ts +++ b/src/vs/workbench/contrib/debug/common/debug.ts @@ -424,6 +424,7 @@ export interface IDebugConfiguration { internalConsoleOptions: 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart'; extensionHostDebugAdapter: boolean; enableAllHovers: boolean; + hideSubSessions: boolean; console: { fontSize: number; fontFamily: string; diff --git a/src/vs/workbench/contrib/debug/common/debugViewModel.ts b/src/vs/workbench/contrib/debug/common/debugViewModel.ts index 1207116cfe0fd..977d6e78afce0 100644 --- a/src/vs/workbench/contrib/debug/common/debugViewModel.ts +++ b/src/vs/workbench/contrib/debug/common/debugViewModel.ts @@ -68,7 +68,7 @@ export class ViewModel implements IViewModel { this.loadedScriptsSupportedContextKey.set(session ? !!session.capabilities.supportsLoadedSourcesRequest : false); this.stepBackSupportedContextKey.set(session ? !!session.capabilities.supportsStepBack : false); this.restartFrameSupportedContextKey.set(session ? !!session.capabilities.supportsRestartFrame : false); - const attach = !!session && session.configuration.request === 'attach' && !isExtensionHostDebugging(session.configuration); + const attach = !!session && !session.parentSession && session.configuration.request === 'attach' && !isExtensionHostDebugging(session.configuration); this.focusedSessionIsAttach.set(attach); if (shouldEmitForSession) { diff --git a/src/vs/workbench/contrib/debug/electron-browser/debugService.ts b/src/vs/workbench/contrib/debug/electron-browser/debugService.ts index 23a7e0ccc0f41..0339ddc086d04 100644 --- a/src/vs/workbench/contrib/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/contrib/debug/electron-browser/debugService.ts @@ -443,8 +443,10 @@ export class DebugService implements IDebugService { } this.viewModel.firstSessionStart = false; - - if (this.model.getSessions().length > 1) { + const hideSubSessions = this.configurationService.getValue('debug').hideSubSessions; + const sessions = this.model.getSessions(); + const shownSessions = hideSubSessions ? sessions.filter(s => !s.parentSession) : sessions; + if (shownSessions.length > 1) { this.viewModel.setMultiSessionView(true); }