From 3f34ed5b77189e616e7d38eaa4ebfbfed6dbe907 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 6 Jul 2017 12:36:42 +0200 Subject: [PATCH] Restrict usages of new ModelLine (#30180) --- src/vs/editor/common/model/editableTextModel.ts | 4 ++-- src/vs/editor/common/model/textModel.ts | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/vs/editor/common/model/editableTextModel.ts b/src/vs/editor/common/model/editableTextModel.ts index 44bcf28c268..66566d1092b 100644 --- a/src/vs/editor/common/model/editableTextModel.ts +++ b/src/vs/editor/common/model/editableTextModel.ts @@ -7,7 +7,7 @@ import { Range, IRange } from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { EditStack } from 'vs/editor/common/model/editStack'; -import { ILineEdit, LineMarker, ModelLine, MarkersTracker, IModelLine } from 'vs/editor/common/model/modelLine'; +import { ILineEdit, LineMarker, MarkersTracker, IModelLine } from 'vs/editor/common/model/modelLine'; import { TextModelWithDecorations, ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations'; import * as strings from 'vs/base/common/strings'; import * as arrays from 'vs/base/common/arrays'; @@ -653,7 +653,7 @@ export class EditableTextModel extends TextModelWithDecorations implements edito let newLinesContent: string[] = []; let newLinesLengths = new Uint32Array(insertingLinesCnt - editingLinesCnt); for (let j = editingLinesCnt + 1; j <= insertingLinesCnt; j++) { - newLines.push(new ModelLine(op.lines[j], tabSize)); + newLines.push(this._createModelLine(op.lines[j], tabSize)); newLinesContent.push(op.lines[j]); newLinesLengths[j - editingLinesCnt - 1] = op.lines[j].length + this._EOL.length; } diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index c371a20a266..f7d1fb623cc 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -115,6 +115,10 @@ export class TextModel implements editorCommon.ITextModel { this._isDisposing = false; } + protected _createModelLine(text: string, tabSize: number): IModelLine { + return new ModelLine(text, tabSize); + } + protected _assertNotDisposed(): void { if (this._isDisposed) { throw new Error('Model is disposed!'); @@ -758,7 +762,7 @@ export class TextModel implements editorCommon.ITextModel { let modelLines: IModelLine[] = []; for (let i = 0, len = rawLines.length; i < len; i++) { - modelLines[i] = new ModelLine(rawLines[i], tabSize); + modelLines[i] = this._createModelLine(rawLines[i], tabSize); } this._BOM = textSource.BOM; this._mightContainRTL = textSource.containsRTL;