diff --git a/packages/debug/src/browser/debug-frontend-application-contribution.ts b/packages/debug/src/browser/debug-frontend-application-contribution.ts index d2aace286052e..27d745ed2966f 100644 --- a/packages/debug/src/browser/debug-frontend-application-contribution.ts +++ b/packages/debug/src/browser/debug-frontend-application-contribution.ts @@ -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']; @@ -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); } }); @@ -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); + } } diff --git a/packages/debug/src/browser/debug-session-manager.ts b/packages/debug/src/browser/debug-session-manager.ts index d5decd2125dc5..19fcb5c9b5546 100644 --- a/packages/debug/src/browser/debug-session-manager.ts +++ b/packages/debug/src/browser/debug-session-manager.ts @@ -210,7 +210,8 @@ export class DebugSessionManager { protected async startConfiguration(options: DebugConfigurationSessionOptions): Promise { 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(); diff --git a/packages/debug/src/common/debug-configuration.ts b/packages/debug/src/common/debug-configuration.ts index 0f11aa7fda064..b987311df3d86 100644 --- a/packages/debug/src/common/debug-configuration.ts +++ b/packages/debug/src/common/debug-configuration.ts @@ -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 { @@ -85,6 +97,9 @@ export interface DebugSessionOptions { consoleMode?: DebugConsoleMode; noDebug?: boolean; compact?: boolean; + suppressSaveBeforeStart?: boolean; + suppressDebugStatusbar?: boolean; + suppressDebugView?: boolean; } export enum DebugConsoleMode { diff --git a/packages/plugin-ext/src/plugin/debug/debug-ext.ts b/packages/plugin-ext/src/plugin/debug/debug-ext.ts index 4bf42e7129a50..498c309d3ffd0 100644 --- a/packages/plugin-ext/src/plugin/debug/debug-ext.ts +++ b/packages/plugin-ext/src/plugin/debug/debug-ext.ts @@ -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 }); diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index 1e13febdf8054..914bcaec6209b 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -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; } /**