Skip to content

Commit

Permalink
[debug] fix #4648: preferences to control view, console and location …
Browse files Browse the repository at this point in the history
…appearance

Signed-off-by: Anton Kosyakov <[email protected]>
  • Loading branch information
akosyakov committed Mar 22, 2019
1 parent 024a835 commit c596067
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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,
Expand All @@ -372,7 +376,9 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
async onStart(): Promise<void> {
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({
Expand Down Expand Up @@ -878,7 +884,7 @@ export class DebugFrontendApplicationContribution extends AbstractViewContributi
}
): Promise<DebugWidget | DebugSessionWidget> {
const { debugViewLocation, reveal } = {
debugViewLocation: session.configuration.debugViewLocation,
debugViewLocation: session.configuration.debugViewLocation || this.preference['debug.debugViewLocation'],
reveal: true,
...options
};
Expand Down
18 changes: 18 additions & 0 deletions packages/debug/src/browser/debug-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
24 changes: 6 additions & 18 deletions packages/debug/src/browser/debug-schema-updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
}
Expand Down

0 comments on commit c596067

Please sign in to comment.