Skip to content

Commit

Permalink
Add boolean suppression DebugSessionOptions
Browse files Browse the repository at this point in the history
Add options to suppress the debugging statusbar, toolbar and view.
As well as the saving before starting a debugging session.

Fixes eclipse-theia#12015

Contributed on behalf of STMicroelectronics
  • Loading branch information
sgraband committed Feb 24, 2023
1 parent cfb005e commit 106149e
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,16 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
activate: false,
});
}
if (!noDebug && (openDebug === 'openOnSessionStart' || (openDebug === 'openOnFirstSessionStart' && this.firstSessionStart))) {
const shouldOpenDebug = openDebug === 'openOnSessionStart' || (openDebug === 'openOnFirstSessionStart' && this.firstSessionStart);
// Do not open debug view when suppressed via configuration
if (!noDebug && !this.shouldViewBeSuppressed(session) && shouldOpenDebug) {
this.openSession(session);
}
this.firstSessionStart = false;
});
this.manager.onDidStopDebugSession(session => {
const { openDebug } = session.configuration;
if (openDebug === 'openOnDebugBreak') {
if (!this.shouldViewBeSuppressed(session) && openDebug === 'openOnDebugBreak') {
this.openSession(session);
}
});
Expand Down Expand Up @@ -1494,10 +1496,36 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
}

const session = this.manager.currentSession;
if (session && session.configuration.noDebug) {
return false;
if (session) {
if (session.configuration.noDebug) {
return false;
}
if (this.getOption(session, 'suppressDebugStatusbar')) {
return false;
}
}

return true;
}

protected getOption(session: DebugSession, option: 'suppressDebugView' | 'suppressDebugToolbar' | 'suppressDebugStatusbar'): boolean | undefined {
// If configuration is not set explicitly take the configuration from the nearest parent.
// This avoid having the configuration being overwritten by undefined values.
let result = session.configuration[option];
let currentSession = session;
while (result === undefined) {
if (currentSession.parentSession) {
currentSession = currentSession.parentSession;
result = currentSession.configuration[option];
} else {
break;
}
}
return result;
}

protected shouldViewBeSuppressed(session: DebugSession): boolean | undefined {
// Only suppress the view if both the debug view and the toolbar are suppressed, as the toolbar is always docked.
return this.getOption(session, 'suppressDebugView') && this.getOption(session, 'suppressDebugToolbar');
}
}
3 changes: 2 additions & 1 deletion packages/debug/src/browser/debug-session-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ export class DebugSessionManager {
protected async startConfiguration(options: DebugConfigurationSessionOptions): Promise<DebugSession | undefined> {
return this.progressService.withProgress('Start...', 'debug', async () => {
try {
if (!await this.saveAll()) {
// If a parent session is available saving should be handled by the parent
if (!options.configuration.parentSessionId && !options.configuration.suppressSaveBeforeStart && !await this.saveAll()) {
return undefined;
}
await this.fireWillStartDebugSession();
Expand Down
19 changes: 19 additions & 0 deletions packages/debug/src/common/debug-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ export interface DebugConfiguration {

/** Task to run after debug session ends */
postDebugTask?: string | TaskIdentifier;

/**
* 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;
}
export namespace DebugConfiguration {
export function is(arg: unknown): arg is DebugConfiguration {
Expand All @@ -85,6 +100,10 @@ export interface DebugSessionOptions {
consoleMode?: DebugConsoleMode;
noDebug?: boolean;
compact?: boolean;
suppressSaveBeforeStart?: boolean;
suppressDebugToolbar?: boolean;
suppressDebugStatusbar?: boolean;
suppressDebugView?: boolean;
}

export enum DebugConsoleMode {
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-ext/src/plugin/debug/debug-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ export class DebugExtImpl implements DebugExt {
parentSessionId: options.parentSession?.id,
compact: options.compact,
consoleMode: options.consoleMode,
suppressSaveBeforeStart: options.suppressSaveBeforeStart,
suppressDebugToolbar: options.suppressDebugToolbar,
suppressDebugStatusbar: options.suppressDebugStatusbar,
suppressDebugView: options.suppressDebugView,
lifecycleManagedByParent: options.lifecycleManagedByParent,
noDebug: options.noDebug
});
Expand Down
21 changes: 21 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11539,6 +11539,27 @@ export module '@theia/plugin' {
* 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

0 comments on commit 106149e

Please sign in to comment.