Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add boolean suppression DebugSessionOptions #12220

Merged
merged 2 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()) {
tsmaeder marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -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