diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index 03400dd02ef9a..c17724ca9ad2c 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -320,23 +320,6 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati this._buffer = textBuffer; this._bufferDisposable = disposable; - this._options = TextModel.resolveOptions(this._buffer, creationOptions); - - const languageId = (typeof languageIdOrSelection === 'string' ? languageIdOrSelection : languageIdOrSelection.languageId); - if (typeof languageIdOrSelection !== 'string') { - this._languageSelectionListener.value = languageIdOrSelection.onDidChange(() => this._setLanguage(languageIdOrSelection.languageId)); - } - - this._bracketPairs = this._register(new BracketPairsTextModelPart(this, this._languageConfigurationService)); - this._guidesTextModelPart = this._register(new GuidesTextModelPart(this, this._languageConfigurationService)); - this._decorationProvider = this._register(new ColorizedBracketPairsDecorationProvider(this)); - this._tokenizationTextModelPart = this.instantiationService.createInstance(TokenizationTextModelPart, - this, - this._bracketPairs, - languageId, - this._attachedViews - ); - const bufferLineCount = this._buffer.getLineCount(); const bufferTextLength = this._buffer.getValueLengthInRange(new Range(1, 1, bufferLineCount, this._buffer.getLineLength(bufferLineCount) + 1), model.EndOfLinePreference.TextDefined); @@ -355,6 +338,23 @@ export class TextModel extends Disposable implements model.ITextModel, IDecorati this._isTooLargeForHeapOperation = false; } + this._options = TextModel.resolveOptions(this._buffer, creationOptions); + + const languageId = (typeof languageIdOrSelection === 'string' ? languageIdOrSelection : languageIdOrSelection.languageId); + if (typeof languageIdOrSelection !== 'string') { + this._languageSelectionListener.value = languageIdOrSelection.onDidChange(() => this._setLanguage(languageIdOrSelection.languageId)); + } + + this._bracketPairs = this._register(new BracketPairsTextModelPart(this, this._languageConfigurationService)); + this._guidesTextModelPart = this._register(new GuidesTextModelPart(this, this._languageConfigurationService)); + this._decorationProvider = this._register(new ColorizedBracketPairsDecorationProvider(this)); + this._tokenizationTextModelPart = this.instantiationService.createInstance(TokenizationTextModelPart, + this, + this._bracketPairs, + languageId, + this._attachedViews + ); + this._isTooLargeForSyncing = (bufferTextLength > TextModel._MODEL_SYNC_LIMIT); this._versionId = 1;