From c59606746fb74c8079294c41d083d9e5bc342ef1 Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Fri, 22 Mar 2019 05:57:30 +0000 Subject: [PATCH] [debug] fix #4648: preferences to control view, console and location appearance Signed-off-by: Anton Kosyakov --- ...debug-frontend-application-contribution.ts | 10 ++++++-- .../debug/src/browser/debug-preferences.ts | 18 ++++++++++++++ .../debug/src/browser/debug-schema-updater.ts | 24 +++++-------------- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/packages/debug/src/browser/debug-frontend-application-contribution.ts b/packages/debug/src/browser/debug-frontend-application-contribution.ts index 66be40bf4b05d..5c0856ae102e1 100644 --- a/packages/debug/src/browser/debug-frontend-application-contribution.ts +++ b/packages/debug/src/browser/debug-frontend-application-contribution.ts @@ -40,6 +40,7 @@ import { DebugEditorService } from './editor/debug-editor-service'; import { DebugConsoleContribution } from './console/debug-console-contribution'; import { DebugService } from '../common/debug-service'; import { DebugSchemaUpdater } from './debug-schema-updater'; +import { DebugPreferences } from './debug-preferences'; export namespace DebugMenus { export const DEBUG = [...MAIN_MENU_BAR, '6_debug']; @@ -346,6 +347,9 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi @inject(DebugSchemaUpdater) protected readonly schemaUpdater: DebugSchemaUpdater; + @inject(DebugPreferences) + protected readonly preference: DebugPreferences; + constructor() { super({ widgetId: DebugWidget.ID, @@ -372,7 +376,9 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi async onStart(): Promise { this.manager.onDidCreateDebugSession(session => this.openSession(session, { reveal: false })); this.manager.onDidStartDebugSession(session => { - const { noDebug, openDebug, internalConsoleOptions } = session.configuration; + const { noDebug } = session.configuration; + const openDebug = session.configuration.openDebug || this.preference['debug.openDebug']; + const internalConsoleOptions = session.configuration.internalConsoleOptions || this.preference['debug.internalConsoleOptions']; if (internalConsoleOptions === 'openOnSessionStart' || (internalConsoleOptions === 'openOnFirstSessionStart' && this.firstSessionStart)) { this.console.openView({ @@ -878,7 +884,7 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi } ): Promise { const { debugViewLocation, reveal } = { - debugViewLocation: session.configuration.debugViewLocation, + debugViewLocation: session.configuration.debugViewLocation || this.preference['debug.debugViewLocation'], reveal: true, ...options }; diff --git a/packages/debug/src/browser/debug-preferences.ts b/packages/debug/src/browser/debug-preferences.ts index 951774d6011fa..94e40814c5125 100644 --- a/packages/debug/src/browser/debug-preferences.ts +++ b/packages/debug/src/browser/debug-preferences.ts @@ -24,12 +24,30 @@ export const debugPreferencesSchema: PreferenceSchema = { type: 'boolean', default: false, description: 'Enable/disable tracing communications with debug adapters' + }, + 'debug.debugViewLocation': { + enum: ['default', 'left', 'right', 'bottom'], + default: 'default', + description: 'Controls the location of the debug view.' + }, + 'debug.openDebug': { + enum: ['neverOpen', 'openOnSessionStart', 'openOnFirstSessionStart', 'openOnDebugBreak'], + default: 'openOnSessionStart', + description: 'Controls when the debug view should open.' + }, + 'debug.internalConsoleOptions': { + enum: ['neverOpen', 'openOnSessionStart', 'openOnFirstSessionStart'], + default: 'openOnFirstSessionStart', + description: 'Controls when the internal debug console should open.' } } }; export class DebugConfiguration { 'debug.trace': boolean; + 'debug.debugViewLocation': 'default' | 'left' | 'right' | 'bottom'; + 'debug.openDebug': 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart' | 'openOnDebugBreak'; + 'debug.internalConsoleOptions': 'neverOpen' | 'openOnSessionStart' | 'openOnFirstSessionStart'; } export const DebugPreferences = Symbol('DebugPreferences'); diff --git a/packages/debug/src/browser/debug-schema-updater.ts b/packages/debug/src/browser/debug-schema-updater.ts index 7b18d64721af1..03e4417718173 100644 --- a/packages/debug/src/browser/debug-schema-updater.ts +++ b/packages/debug/src/browser/debug-schema-updater.ts @@ -20,6 +20,7 @@ import { InMemoryResources, deepClone } from '@theia/core/lib/common'; import { IJSONSchema } from '@theia/core/lib/common/json-schema'; import URI from '@theia/core/lib/common/uri'; import { DebugService } from '../common/debug-service'; +import { debugPreferencesSchema } from './debug-preferences'; @injectable() export class DebugSchemaUpdater { @@ -37,24 +38,11 @@ export class DebugSchemaUpdater { const attributePromises = types.map(type => this.debug.getSchemaAttributes(type)); for (const attributes of await Promise.all(attributePromises)) { for (const attribute of attributes) { - attribute.properties = { - 'debugViewLocation': { - enum: ['default', 'left', 'right', 'bottom'], - default: 'default', - description: 'Controls the location of the debug view.' - }, - 'openDebug': { - enum: ['neverOpen', 'openOnSessionStart', 'openOnFirstSessionStart', 'openOnDebugBreak'], - default: 'openOnSessionStart', - description: 'Controls when the debug view should open.' - }, - 'internalConsoleOptions': { - enum: ['neverOpen', 'openOnSessionStart', 'openOnFirstSessionStart'], - default: 'openOnFirstSessionStart', - description: 'Controls when the internal debug console should open.' - }, - ...attribute.properties - }; + const properties: typeof attribute['properties'] = {}; + for (const key of ['debugViewLocation', 'openDebug', 'internalConsoleOptions']) { + properties[key] = debugPreferencesSchema.properties[`debug.${key}`]; + } + attribute.properties = Object.assign(properties, attribute.properties); items.oneOf!.push(attribute); } }