Skip to content

Commit

Permalink
Add boolean suppression DebugSessionOptions (#12220)
Browse files Browse the repository at this point in the history
* Add boolean suppression DebugSessionOptions

Add options to suppress the debugging statusbar, toolbar and view.
As well as the saving before starting a debugging session.

Fixes #12015

Contributed on behalf of STMicroelectronics
  • Loading branch information
sgraband authored Mar 17, 2023
1 parent ff944de commit 16be9ac
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { DebugFunctionBreakpoint } from './model/debug-function-breakpoint';
import { DebugBreakpoint } from './model/debug-breakpoint';
import { nls } from '@theia/core/lib/common/nls';
import { DebugInstructionBreakpoint } from './model/debug-instruction-breakpoint';
import { DebugConfiguration } from '../common/debug-configuration';

export namespace DebugMenus {
export const DEBUG = [...MAIN_MENU_BAR, '6_debug'];
Expand Down Expand Up @@ -449,14 +450,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.getOption(session, 'suppressDebugView') && shouldOpenDebug) {
this.openSession(session);
}
this.firstSessionStart = false;
});
this.manager.onDidStopDebugSession(session => {
const { openDebug } = session.configuration;
if (openDebug === 'openOnDebugBreak') {
if (!this.getOption(session, 'suppressDebugView') && openDebug === 'openOnDebugBreak') {
this.openSession(session);
}
});
Expand Down Expand Up @@ -1494,10 +1497,30 @@ 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 | undefined, option: keyof {
[Property in keyof DebugConfiguration]: boolean;
}): boolean | undefined {
// If session is undefined there will be no option
if (!session) {
return false;
}
// If undefined take the value of the parent
if (option in session.configuration && session.configuration[option] !== undefined) {
return session.configuration[option];
}

return this.getOption(session.parentSession, option);
}
}
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
15 changes: 15 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,18 @@ 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 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 +97,9 @@ export interface DebugSessionOptions {
consoleMode?: DebugConsoleMode;
noDebug?: boolean;
compact?: boolean;
suppressSaveBeforeStart?: boolean;
suppressDebugStatusbar?: boolean;
suppressDebugView?: boolean;
}

export enum DebugConsoleMode {
Expand Down
3 changes: 3 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,9 @@ export class DebugExtImpl implements DebugExt {
parentSessionId: options.parentSession?.id,
compact: options.compact,
consoleMode: options.consoleMode,
suppressSaveBeforeStart: options.suppressSaveBeforeStart,
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 @@ -11585,6 +11585,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 16be9ac

Please sign in to comment.