Skip to content

Commit

Permalink
Finalize notebookDebugOptions API (#163316)
Browse files Browse the repository at this point in the history
* Finalize notebookDebugOptions API
Fix #147264

* Backcompat for the option from vscode-jupyter

* Undo comment

* Fix build
  • Loading branch information
roblourens authored Oct 12, 2022
1 parent fdb8812 commit cf47b76
Show file tree
Hide file tree
Showing 15 changed files with 77 additions and 63 deletions.
1 change: 0 additions & 1 deletion extensions/vscode-api-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"notebookCellExecutionState",
"notebookContentProvider",
"notebookControllerKind",
"notebookDebugOptions",
"notebookDeprecated",
"notebookLiveShare",
"notebookMessaging",
Expand Down
7 changes: 5 additions & 2 deletions src/vs/workbench/api/browser/mainThreadDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,12 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb
lifecycleManagedByParent: options.lifecycleManagedByParent,
repl: options.repl,
compact: options.compact,
debugUI: options.debugUI,
compoundRoot: parentSession?.compoundRoot,
saveBeforeRestart: saveBeforeStart
saveBeforeRestart: saveBeforeStart,

suppressDebugStatusbar: options.suppressDebugStatusbar,
suppressDebugToolbar: options.suppressDebugToolbar,
suppressDebugView: options.suppressDebugView,
};
try {
return this.debugService.startDebugging(launch, nameOrConfig, debugOptions, saveBeforeStart);
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1226,9 +1226,9 @@ export interface IStartDebuggingOptions {
repl?: IDebugSessionReplMode;
noDebug?: boolean;
compact?: boolean;
debugUI?: {
simple?: boolean;
};
suppressDebugToolbar?: boolean;
suppressDebugStatusbar?: boolean;
suppressDebugView?: boolean;
suppressSaveBeforeStart?: boolean;
}

Expand Down
8 changes: 6 additions & 2 deletions src/vs/workbench/api/common/extHostDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,12 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
repl: options.consoleMode === DebugConsoleMode.MergeWithParent ? 'mergeWithParent' : 'separate',
noDebug: options.noDebug,
compact: options.compact,
debugUI: options.debugUI,
suppressSaveBeforeStart: options.suppressSaveBeforeStart
suppressSaveBeforeStart: options.suppressSaveBeforeStart,

// Check debugUI for back-compat, #147264
suppressDebugStatusbar: options.suppressDebugStatusbar ?? (options as any).debugUI?.simple,
suppressDebugToolbar: options.suppressDebugToolbar ?? (options as any).debugUI?.simple,
suppressDebugView: options.suppressDebugView ?? (options as any).debugUI?.simple,
});
}

Expand Down
4 changes: 0 additions & 4 deletions src/vs/workbench/contrib/debug/browser/callStackView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,6 @@ class ThreadsRenderer implements ICompressibleTreeRenderer<IThread, FuzzyScore,
templateData.elementDisposable.clear();
}

disposeCompressedElements(node: ITreeNode<ICompressedTreeNode<IThread>, FuzzyScore>, index: number, templateData: IThreadTemplateData, height: number | undefined): void {
templateData.elementDisposable.clear();
}

disposeTemplate(templateData: IThreadTemplateData): void {
templateData.templateDisposable.dispose();
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/debug/browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ export class DebugService implements IDebugService {

const openDebug = this.configurationService.getValue<IDebugConfiguration>('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)) && !session.isSimpleUI) {
if (!configuration.resolved.noDebug && (openDebug === 'openOnSessionStart' || (openDebug !== 'neverOpen' && this.viewModel.firstSessionStart)) && !session.suppressDebugView) {
await this.paneCompositeService.openPaneComposite(VIEWLET_ID, ViewContainerLocation.Sidebar);
}

Expand Down
15 changes: 12 additions & 3 deletions src/vs/workbench/contrib/debug/browser/debugSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,19 @@ export class DebugSession implements IDebugSession {
return this._options.compoundRoot;
}

get isSimpleUI(): boolean {
return this._options.debugUI?.simple ?? false;
get suppressDebugStatusbar(): boolean {
return this._options.suppressDebugStatusbar ?? false;
}

get suppressDebugToolbar(): boolean {
return this._options.suppressDebugToolbar ?? false;
}

get suppressDebugView(): boolean {
return this._options.suppressDebugView ?? false;
}


get autoExpandLazyVariables(): boolean {
// This tiny helper avoids converting the entire debug model to use service injection
return this.configurationService.getValue<IDebugConfiguration>('debug').autoExpandLazyVariables;
Expand Down Expand Up @@ -971,7 +980,7 @@ export class DebugSession implements IDebugSession {
}

if (thread.stoppedDetails) {
if (thread.stoppedDetails.reason === 'breakpoint' && this.configurationService.getValue<IDebugConfiguration>('debug').openDebug === 'openOnDebugBreak' && !this.isSimpleUI) {
if (thread.stoppedDetails.reason === 'breakpoint' && this.configurationService.getValue<IDebugConfiguration>('debug').openDebug === 'openOnDebugBreak' && !this.suppressDebugView) {
await this.paneCompositeService.openPaneComposite(VIEWLET_ID, ViewContainerLocation.Sidebar);
}

Expand Down
8 changes: 7 additions & 1 deletion src/vs/workbench/contrib/debug/browser/debugToolBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ export class DebugToolBar extends Themable implements IWorkbenchContribution {
this.updateScheduler = this._register(new RunOnceScheduler(() => {
const state = this.debugService.state;
const toolBarLocation = this.configurationService.getValue<IDebugConfiguration>('debug').toolBarLocation;
if (state === State.Inactive || toolBarLocation === 'docked' || toolBarLocation === 'hidden' || this.debugService.getViewModel().focusedSession?.isSimpleUI || (state === State.Initializing && this.debugService.initializingOptions?.debugUI?.simple)) {
if (
state === State.Inactive ||
toolBarLocation === 'docked' ||
toolBarLocation === 'hidden' ||
this.debugService.getModel().getSessions().every(s => s.suppressDebugToolbar) ||
(state === State.Initializing && this.debugService.initializingOptions?.suppressDebugToolbar)
) {
return this.hide();
}

Expand Down
10 changes: 3 additions & 7 deletions src/vs/workbench/contrib/debug/browser/statusbarColorProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class StatusBarColorProvider implements IWorkbenchContribution {
}

protected update(): void {
this.enabled = isStatusbarInDebugMode(this.debugService.state, this.debugService.getViewModel().focusedSession);
this.enabled = isStatusbarInDebugMode(this.debugService.state, this.debugService.getModel().getSessions());
}

dispose(): void {
Expand All @@ -78,12 +78,8 @@ export class StatusBarColorProvider implements IWorkbenchContribution {
}
}

export function isStatusbarInDebugMode(state: State, session: IDebugSession | undefined): boolean {
if (state === State.Inactive || state === State.Initializing || session?.isSimpleUI) {
return false;
}
const isRunningWithoutDebug = session?.configuration?.noDebug;
if (isRunningWithoutDebug) {
export function isStatusbarInDebugMode(state: State, sessions: IDebugSession[]): boolean {
if (state === State.Inactive || state === State.Initializing || sessions.every(s => s.suppressDebugStatusbar || s.configuration?.noDebug)) {
return false;
}

Expand Down
10 changes: 6 additions & 4 deletions src/vs/workbench/contrib/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ export interface IDebugSessionOptions {
repl?: IDebugSessionReplMode;
compoundRoot?: DebugCompoundRoot;
compact?: boolean;
debugUI?: {
simple?: boolean;
};
startedByUser?: boolean;
saveBeforeRestart?: boolean;
suppressDebugToolbar?: boolean;
suppressDebugStatusbar?: boolean;
suppressDebugView?: boolean;
}

export interface IDataBreakpointInfoResponse {
Expand Down Expand Up @@ -300,8 +300,10 @@ export interface IDebugSession extends ITreeElement {
readonly compoundRoot: DebugCompoundRoot | undefined;
readonly saveBeforeRestart: boolean;
readonly name: string;
readonly isSimpleUI: boolean;
readonly autoExpandLazyVariables: boolean;
readonly suppressDebugToolbar: boolean;
readonly suppressDebugStatusbar: boolean;
readonly suppressDebugView: boolean;

setSubId(subId: string | undefined): void;

Expand Down
16 changes: 11 additions & 5 deletions src/vs/workbench/contrib/debug/test/browser/baseDebugView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,17 @@ suite('Debug - Base Debug View', () => {
test('statusbar in debug mode', () => {
const model = createMockDebugModel();
const session = createMockSession(model);
assert.strictEqual(isStatusbarInDebugMode(State.Inactive, undefined), false);
assert.strictEqual(isStatusbarInDebugMode(State.Initializing, session), false);
assert.strictEqual(isStatusbarInDebugMode(State.Running, session), true);
assert.strictEqual(isStatusbarInDebugMode(State.Stopped, session), true);
const session2 = createMockSession(model, undefined, { suppressDebugStatusbar: true });
assert.strictEqual(isStatusbarInDebugMode(State.Inactive, []), false);
assert.strictEqual(isStatusbarInDebugMode(State.Initializing, [session]), false);
assert.strictEqual(isStatusbarInDebugMode(State.Running, [session]), true);
assert.strictEqual(isStatusbarInDebugMode(State.Stopped, [session]), true);

assert.strictEqual(isStatusbarInDebugMode(State.Running, [session2]), false);
assert.strictEqual(isStatusbarInDebugMode(State.Running, [session, session2]), true);

session.configuration.noDebug = true;
assert.strictEqual(isStatusbarInDebugMode(State.Running, session), false);
assert.strictEqual(isStatusbarInDebugMode(State.Running, [session]), false);
assert.strictEqual(isStatusbarInDebugMode(State.Running, [session, session2]), false);
});
});
3 changes: 3 additions & 0 deletions src/vs/workbench/contrib/debug/test/browser/mockDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ export class MockDebugService implements IDebugService {
}

export class MockSession implements IDebugSession {
readonly suppressDebugToolbar = false;
readonly suppressDebugStatusbar = false;
readonly suppressDebugView = false;
readonly autoExpandLazyVariables = false;

getMemory(memoryReference: string): IMemoryRegion {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const allApiProposals = Object.freeze({
notebookContentProvider: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookContentProvider.d.ts',
notebookControllerAffinityHidden: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookControllerAffinityHidden.d.ts',
notebookControllerKind: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookControllerKind.d.ts',
notebookDebugOptions: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookDebugOptions.d.ts',
notebookDeprecated: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookDeprecated.d.ts',
notebookEditor: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookEditor.d.ts',
notebookKernelSource: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.notebookKernelSource.d.ts',
Expand Down
20 changes: 20 additions & 0 deletions src/vscode-dts/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14828,6 +14828,26 @@ declare module 'vscode' {
* If compact is true, debug sessions with a single child are hidden in the CALL STACK view to make the tree more compact.
*/
compact?: boolean;

/**
* When true, a save will not be triggered for open editors when starting a debug session, regardless of the value of the `debug.saveBeforeStart` setting.
*/
suppressSaveBeforeStart?: boolean;

/**
* When true, the debug toolbar will not be shown for this session.
*/
suppressDebugToolbar?: boolean;

/**
* When true, the window statusbar color will not be changed for this session.
*/
suppressDebugStatusbar?: boolean;

/**
* When true, the debug viewlet will not be automatically revealed for this session.
*/
suppressDebugView?: boolean;
}

/**
Expand Down
29 changes: 0 additions & 29 deletions src/vscode-dts/vscode.proposed.notebookDebugOptions.d.ts

This file was deleted.

0 comments on commit cf47b76

Please sign in to comment.