Skip to content

Commit ec3673e

Browse files
committed
Fix 'super' must be called before accessing 'this' in Configuration
1 parent 225a0f5 commit ec3673e

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/vs/editor/browser/config/configuration.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,8 @@ export class Configuration extends CommonEditorConfiguration {
269269
}
270270
}
271271

272-
private _elementSizeObserver: ElementSizeObserver;
273-
274272
constructor(options:any, referenceDomElement:HTMLElement = null, indentationGuesser:(tabSize:number)=>IGuessedIndentation = null) {
275-
this._elementSizeObserver = new ElementSizeObserver(referenceDomElement, () => this._onReferenceDomElementSizeChanged());
276-
277-
super(options, indentationGuesser);
273+
super(options, new ElementSizeObserver(referenceDomElement, () => this._onReferenceDomElementSizeChanged()), indentationGuesser);
278274

279275
this._register(CSSBasedConfiguration.INSTANCE.onDidChange(() => () => this._onCSSBasedConfigurationChanged()));
280276

src/vs/editor/browser/config/elementSizeObserver.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
import {Disposable} from 'vs/base/common/lifecycle';
88
import {IDimension} from 'vs/editor/common/editorCommon';
9+
import {IElementSizeObserver} from 'vs/editor/common/config/commonEditorConfig';
910

10-
export class ElementSizeObserver extends Disposable {
11+
export class ElementSizeObserver extends Disposable implements IElementSizeObserver {
1112

1213
private referenceDomElement:HTMLElement;
1314
private measureReferenceDomElementToken:number;

src/vs/editor/common/config/commonEditorConfig.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,13 +550,22 @@ export interface IIndentationGuesser {
550550
(tabSize:number): editorCommon.IGuessedIndentation;
551551
}
552552

553+
export interface IElementSizeObserver {
554+
startObserving(): void;
555+
observe(dimension?:editorCommon.IDimension): void;
556+
dispose(): void;
557+
getWidth(): number;
558+
getHeight(): number;
559+
}
560+
553561
export abstract class CommonEditorConfiguration extends Disposable implements editorCommon.IConfiguration {
554562

555563
public handlerDispatcher:editorCommon.IHandlerDispatcher;
556564
public editor:editorCommon.IInternalEditorOptions;
557565
public editorClone:editorCommon.IInternalEditorOptions;
558566

559567
protected _configWithDefaults:ConfigurationWithDefaults;
568+
protected _elementSizeObserver: IElementSizeObserver;
560569
private _indentationGuesser:IIndentationGuesser;
561570
private _cachedGuessedIndentationTabSize: number;
562571
private _cachedGuessedIndentation:editorCommon.IGuessedIndentation;
@@ -566,9 +575,10 @@ export abstract class CommonEditorConfiguration extends Disposable implements ed
566575
private _onDidChange = this._register(new Emitter<editorCommon.IConfigurationChangedEvent>());
567576
public onDidChange: Event<editorCommon.IConfigurationChangedEvent> = this._onDidChange.event;
568577

569-
constructor(options:any, indentationGuesser:IIndentationGuesser = null) {
578+
constructor(options:any, elementSizeObserver: IElementSizeObserver = null, indentationGuesser:IIndentationGuesser = null) {
570579
super();
571580
this._configWithDefaults = new ConfigurationWithDefaults(options);
581+
this._elementSizeObserver = elementSizeObserver;
572582
this._indentationGuesser = indentationGuesser;
573583
this._cachedGuessedIndentationTabSize = -1;
574584
this._cachedGuessedIndentation = null;

0 commit comments

Comments
 (0)