Restrict usages of new ModelLine (#30180)

This commit is contained in:
Alex Dima
2017-07-06 13:02:26 +02:00
parent 4f3327d982
commit 3f34ed5b77
2 changed files with 7 additions and 3 deletions
@@ -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;
}
+5 -1
View File
@@ -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;