Skip to content

Commit

Permalink
Eliminate ModelLine._lineNumber usage in ModelLine.append (#30180)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Jul 6, 2017
1 parent 414dc3a commit 1b982d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/vs/editor/common/model/editableTextModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
}

// Reconstruct first line
this._lines[spliceStartLineNumber - 1].append(markersTracker, endLineRemains, tabSize);
this._lines[spliceStartLineNumber - 1].append(markersTracker, spliceStartLineNumber, endLineRemains, tabSize);
if (this._lineStarts) {
// update prefix sum
this._lineStarts.changeValue(spliceStartLineNumber - 1, this._lines[spliceStartLineNumber - 1].text.length + this._EOL.length);
Expand Down Expand Up @@ -666,7 +666,7 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
}

// Last line
this._lines[startLineNumber + insertingLinesCnt - 1].append(markersTracker, leftoverLine, tabSize);
this._lines[startLineNumber + insertingLinesCnt - 1].append(markersTracker, startLineNumber + insertingLinesCnt, leftoverLine, tabSize);
if (this._lineStarts) {
// update prefix sum
this._lineStarts.changeValue(startLineNumber + insertingLinesCnt - 1, this._lines[startLineNumber + insertingLinesCnt - 1].text.length + this._EOL.length);
Expand Down Expand Up @@ -739,7 +739,7 @@ export class EditableTextModel extends TextModelWithDecorations implements edito
foundMarkersCnt++;
let markerId = markers[j].id;
let marker = this._markerIdToMarker[markerId];
if (marker.position.lineNumber !== line.lineNumber) {
if (marker.position.lineNumber !== lineNumber) {
throw new Error('Misplaced marker with id ' + markerId);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/vs/editor/common/model/modelLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ export class ModelLine {
return otherLine;
}

public append(markersTracker: MarkersTracker, other: ModelLine, tabSize: number): void {
public append(markersTracker: MarkersTracker, myLineNumber: number, other: ModelLine, tabSize: number): void {
// console.log('--> append: THIS :: ' + this._printMarkers());
// console.log('--> append: OTHER :: ' + this._printMarkers());
let thisTextLength = this._text.length;
Expand Down Expand Up @@ -656,7 +656,7 @@ export class ModelLine {
for (let i = 0, len = otherMarkers.length; i < len; i++) {
let marker = otherMarkers[i];

marker.updatePosition(markersTracker, new Position(this._lineNumber, marker.position.column + thisTextLength));
marker.updatePosition(markersTracker, new Position(myLineNumber, marker.position.column + thisTextLength));
}

this.addMarkers(otherMarkers);
Expand Down
6 changes: 3 additions & 3 deletions src/vs/editor/test/common/model/model.line.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ suite('Editor Model - modelLine.append text', () => {
function testLineAppend(a: string, b: string, expected: string): void {
var line1 = new ModelLine(1, a, NO_TAB_SIZE);
var line2 = new ModelLine(2, b, NO_TAB_SIZE);
line1.append(new MarkersTracker(), line2, NO_TAB_SIZE);
line1.append(new MarkersTracker(), 1, line2, NO_TAB_SIZE);
assert.equal(line1.text, expected);
}

Expand Down Expand Up @@ -960,7 +960,7 @@ suite('Editor Model - modelLine.append text & tokens', () => {
let b = new ModelLine(2, bText, NO_TAB_SIZE);
b.setTokens(0, TestToken.toTokens(bTokens));

a.append(new MarkersTracker(), b, NO_TAB_SIZE);
a.append(new MarkersTracker(), 1, b, NO_TAB_SIZE);

assert.equal(a.text, expectedText);
assertLineTokens(a.getTokens(0), expectedTokens);
Expand Down Expand Up @@ -2191,7 +2191,7 @@ suite('Editor Model - modelLine.append text & markers', () => {
b.addMarkers(bMarkers);

let changedMarkers = new MarkersTracker();
a.append(changedMarkers, b, NO_TAB_SIZE);
a.append(changedMarkers, 1, b, NO_TAB_SIZE);

assert.equal(a.text, expectedText, 'text');

Expand Down

0 comments on commit 1b982d3

Please sign in to comment.