From 247e62d79afc470f9aee6b68932af80b195dca17 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Mon, 19 Jul 2021 17:49:17 -0700 Subject: [PATCH] Add flag for "simple" debug UI (#128801) * Implement simple debug UI mode * Don't show debug viewlet on step * Move flag to proposed * Pass around full debugUI options object * Implement isSimpleUI in mock --- src/vs/vscode.proposed.d.ts | 7 +++++++ .../workbench/api/browser/mainThreadDebugService.ts | 1 + src/vs/workbench/api/common/extHost.protocol.ts | 3 +++ src/vs/workbench/api/common/extHostDebugService.ts | 3 ++- .../workbench/contrib/debug/browser/debugService.ts | 13 ++++++++++--- .../workbench/contrib/debug/browser/debugSession.ts | 6 +++++- .../workbench/contrib/debug/browser/debugToolBar.ts | 2 +- .../contrib/debug/browser/statusbarColorProvider.ts | 2 +- src/vs/workbench/contrib/debug/common/debug.ts | 6 ++++++ .../contrib/debug/test/browser/mockDebug.ts | 4 ++++ 10 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index a7e464f48a4..7aa140f84bf 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -697,6 +697,13 @@ declare module 'vscode' { * This property is ignored if the session has no parent session. */ lifecycleManagedByParent?: boolean; + + debugUI?: { + /** + * When true, the debug toolbar will not be shown for this session, the window statusbar color will not be changed, and the debug viewlet will not be automatically revealed. + */ + simple?: boolean; + } } //#endregion diff --git a/src/vs/workbench/api/browser/mainThreadDebugService.ts b/src/vs/workbench/api/browser/mainThreadDebugService.ts index 60c3a74c017..57a33806371 100644 --- a/src/vs/workbench/api/browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/browser/mainThreadDebugService.ts @@ -228,6 +228,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb parentSession, repl: options.repl, compact: options.compact, + debugUI: options.debugUI, compoundRoot: parentSession?.compoundRoot }; return this.debugService.startDebugging(launch, nameOrConfig, debugOptions).then(success => { diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 97b95bef94f..2a4e3c09f1a 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -1097,6 +1097,9 @@ export interface IStartDebuggingOptions { repl?: IDebugSessionReplMode; noDebug?: boolean; compact?: boolean; + debugUI?: { + simple?: boolean; + }; } export interface MainThreadDebugServiceShape extends IDisposable { diff --git a/src/vs/workbench/api/common/extHostDebugService.ts b/src/vs/workbench/api/common/extHostDebugService.ts index 406992259f6..4036d60e099 100644 --- a/src/vs/workbench/api/common/extHostDebugService.ts +++ b/src/vs/workbench/api/common/extHostDebugService.ts @@ -291,7 +291,8 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E parentSessionID: options.parentSession ? options.parentSession.id : undefined, repl: options.consoleMode === DebugConsoleMode.MergeWithParent ? 'mergeWithParent' : 'separate', noDebug: options.noDebug, - compact: options.compact + compact: options.compact, + debugUI: options.debugUI }); } diff --git a/src/vs/workbench/contrib/debug/browser/debugService.ts b/src/vs/workbench/contrib/debug/browser/debugService.ts index c599e144f2a..9cd2f9d8bb6 100644 --- a/src/vs/workbench/contrib/debug/browser/debugService.ts +++ b/src/vs/workbench/contrib/debug/browser/debugService.ts @@ -74,6 +74,7 @@ export class DebugService implements IDebugService { private breakpointsExist!: IContextKey; private breakpointsToSendOnResourceSaved: Set; private initializing = false; + private _initializingOptions: IDebugSessionOptions | undefined; private previousState: State | undefined; private sessionCancellationTokens = new Map(); private activity: IDisposable | undefined; @@ -213,9 +214,14 @@ export class DebugService implements IDebugService { return this.initializing ? State.Initializing : State.Inactive; } - private startInitializingState(): void { + get initializingOptions(): IDebugSessionOptions | undefined { + return this._initializingOptions; + } + + private startInitializingState(options?: IDebugSessionOptions): void { if (!this.initializing) { this.initializing = true; + this._initializingOptions = options; this.onStateChange(); } } @@ -223,6 +229,7 @@ export class DebugService implements IDebugService { private endInitializingState(): void { if (this.initializing) { this.initializing = false; + this._initializingOptions = undefined; this.onStateChange(); } } @@ -284,7 +291,7 @@ export class DebugService implements IDebugService { if (!trust) { return false; } - this.startInitializingState(); + this.startInitializingState(options); try { // make sure to save all files and that the configuration is up to date await this.extensionService.activateByEvent('onDebug'); @@ -524,7 +531,7 @@ export class DebugService implements IDebugService { const openDebug = this.configurationService.getValue('debug').openDebug; // Open debug viewlet based on the visibility of the side bar and openDebug setting. Do not open for 'run without debug' - if (!configuration.resolved.noDebug && (openDebug === 'openOnSessionStart' || (openDebug !== 'neverOpen' && this.viewModel.firstSessionStart))) { + if (!configuration.resolved.noDebug && (openDebug === 'openOnSessionStart' || (openDebug !== 'neverOpen' && this.viewModel.firstSessionStart)) && !session.isSimpleUI) { await this.viewletService.openViewlet(VIEWLET_ID); } diff --git a/src/vs/workbench/contrib/debug/browser/debugSession.ts b/src/vs/workbench/contrib/debug/browser/debugSession.ts index 058ab97e711..bac58924954 100644 --- a/src/vs/workbench/contrib/debug/browser/debugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/debugSession.ts @@ -139,6 +139,10 @@ export class DebugSession implements IDebugSession { return this._options.compoundRoot; } + get isSimpleUI(): boolean { + return this._options.debugUI?.simple ?? false; + } + setConfiguration(configuration: { resolved: IConfig, unresolved: IConfig | undefined }) { this._configuration = configuration; } @@ -836,7 +840,7 @@ export class DebugSession implements IDebugSession { if (!event.body.preserveFocusHint && thread.getCallStack().length) { await this.debugService.focusStackFrame(undefined, thread); if (thread.stoppedDetails) { - if (this.configurationService.getValue('debug').openDebug === 'openOnDebugBreak') { + if (this.configurationService.getValue('debug').openDebug === 'openOnDebugBreak' && !this.isSimpleUI) { this.viewletService.openViewlet(VIEWLET_ID); } diff --git a/src/vs/workbench/contrib/debug/browser/debugToolBar.ts b/src/vs/workbench/contrib/debug/browser/debugToolBar.ts index eef15c3a7c0..c65d4b8c00b 100644 --- a/src/vs/workbench/contrib/debug/browser/debugToolBar.ts +++ b/src/vs/workbench/contrib/debug/browser/debugToolBar.ts @@ -87,7 +87,7 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution { this.updateScheduler = this._register(new RunOnceScheduler(() => { const state = this.debugService.state; const toolBarLocation = this.configurationService.getValue('debug').toolBarLocation; - if (state === State.Inactive || toolBarLocation === 'docked' || toolBarLocation === 'hidden') { + if (state === State.Inactive || toolBarLocation === 'docked' || toolBarLocation === 'hidden' || this.debugService.getViewModel().focusedSession?.isSimpleUI || (state === State.Initializing && this.debugService.initializingOptions?.debugUI?.simple)) { return this.hide(); } diff --git a/src/vs/workbench/contrib/debug/browser/statusbarColorProvider.ts b/src/vs/workbench/contrib/debug/browser/statusbarColorProvider.ts index 48207bde922..e26f8e64bf9 100644 --- a/src/vs/workbench/contrib/debug/browser/statusbarColorProvider.ts +++ b/src/vs/workbench/contrib/debug/browser/statusbarColorProvider.ts @@ -104,7 +104,7 @@ export class StatusBarColorProvider extends Themable implements IWorkbenchContri } export function isStatusbarInDebugMode(state: State, session: IDebugSession | undefined): boolean { - if (state === State.Inactive || state === State.Initializing) { + if (state === State.Inactive || state === State.Initializing || session?.isSimpleUI) { return false; } const isRunningWithoutDebug = session?.configuration?.noDebug; diff --git a/src/vs/workbench/contrib/debug/common/debug.ts b/src/vs/workbench/contrib/debug/common/debug.ts index 68999dc311b..6a9b9810c48 100644 --- a/src/vs/workbench/contrib/debug/common/debug.ts +++ b/src/vs/workbench/contrib/debug/common/debug.ts @@ -180,6 +180,9 @@ export interface IDebugSessionOptions { repl?: IDebugSessionReplMode; compoundRoot?: DebugCompoundRoot; compact?: boolean; + debugUI?: { + simple?: boolean; + }; } export interface IDataBreakpointInfoResponse { @@ -200,6 +203,7 @@ export interface IDebugSession extends ITreeElement { readonly compact: boolean; readonly compoundRoot: DebugCompoundRoot | undefined; readonly name: string; + readonly isSimpleUI: boolean; setSubId(subId: string | undefined): void; @@ -789,6 +793,8 @@ export interface IDebugService { */ readonly state: State; + readonly initializingOptions?: IDebugSessionOptions | undefined; + /** * Allows to register on debug state changes. */ diff --git a/src/vs/workbench/contrib/debug/test/browser/mockDebug.ts b/src/vs/workbench/contrib/debug/test/browser/mockDebug.ts index ef687d5cbdf..8851299650e 100644 --- a/src/vs/workbench/contrib/debug/test/browser/mockDebug.ts +++ b/src/vs/workbench/contrib/debug/test/browser/mockDebug.ts @@ -163,6 +163,10 @@ export class MockSession implements IDebugSession { return undefined; } + get isSimpleUI(): boolean { + return false; + } + stepInTargets(frameId: number): Promise<{ id: number; label: string; }[]> { throw new Error('Method not implemented.'); }