Skip to content

Commit 4ebad70

Browse files
committed
SingleLineEdit -> LineReplacement
1 parent aa095f8 commit 4ebad70

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/vs/editor/common/core/edits/lineEdit.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class LineEdit {
1717
public static readonly empty = new LineEdit([]);
1818

1919
public static deserialize(data: SerializedLineEdit): LineEdit {
20-
return new LineEdit(data.map(e => SingleLineEdit.deserialize(e)));
20+
return new LineEdit(data.map(e => LineReplacement.deserialize(e)));
2121
}
2222

2323
public static fromEdit(edit: StringEdit, initialValue: AbstractText): LineEdit {
@@ -28,7 +28,7 @@ export class LineEdit {
2828
public static fromTextEdit(edit: TextEdit, initialValue: AbstractText): LineEdit {
2929
const edits = edit.replacements;
3030

31-
const result: SingleLineEdit[] = [];
31+
const result: LineReplacement[] = [];
3232

3333
const currentEdits: TextReplacement[] = [];
3434
for (let i = 0; i < edits.length; i++) {
@@ -42,14 +42,14 @@ export class LineEdit {
4242
const singleEdit = TextReplacement.joinReplacements(currentEdits, initialValue);
4343
currentEdits.length = 0;
4444

45-
const singleLineEdit = SingleLineEdit.fromSingleTextEdit(singleEdit, initialValue);
45+
const singleLineEdit = LineReplacement.fromSingleTextEdit(singleEdit, initialValue);
4646
result.push(singleLineEdit);
4747
}
4848

4949
return new LineEdit(result);
5050
}
5151

52-
public static createFromUnsorted(edits: readonly SingleLineEdit[]): LineEdit {
52+
public static createFromUnsorted(edits: readonly LineReplacement[]): LineEdit {
5353
const result = edits.slice();
5454
result.sort(compareBy(i => i.lineRange.startLineNumber, numberComparator));
5555
return new LineEdit(result);
@@ -59,7 +59,7 @@ export class LineEdit {
5959
/**
6060
* Have to be sorted by start line number and non-intersecting.
6161
*/
62-
public readonly edits: readonly SingleLineEdit[]
62+
public readonly edits: readonly LineReplacement[]
6363
) {
6464
assert(checkAdjacentItems(edits, (i1, i2) => i1.lineRange.endLineNumberExclusive <= i2.lineRange.startLineNumber));
6565
}
@@ -112,7 +112,7 @@ export class LineEdit {
112112

113113
public rebase(base: LineEdit): LineEdit {
114114
return new LineEdit(
115-
this.edits.map(e => new SingleLineEdit(base.mapLineRange(e.lineRange), e.newLines)),
115+
this.edits.map(e => new LineReplacement(base.mapLineRange(e.lineRange), e.newLines)),
116116
);
117117
}
118118

@@ -208,15 +208,15 @@ export class LineEdit {
208208
}
209209
}
210210

211-
export class SingleLineEdit {
212-
public static deserialize(e: SerializedSingleLineEdit): SingleLineEdit {
213-
return new SingleLineEdit(
211+
export class LineReplacement {
212+
public static deserialize(e: SerializedSingleLineEdit): LineReplacement {
213+
return new LineReplacement(
214214
LineRange.ofLength(e[0], e[1] - e[0]),
215215
e[2],
216216
);
217217
}
218218

219-
public static fromSingleTextEdit(edit: TextReplacement, initialValue: AbstractText): SingleLineEdit {
219+
public static fromSingleTextEdit(edit: TextReplacement, initialValue: AbstractText): LineReplacement {
220220
// 1: ab[cde
221221
// 2: fghijk
222222
// 3: lmn]opq
@@ -262,7 +262,7 @@ export class SingleLineEdit {
262262
newLines.pop();
263263
}
264264

265-
return new SingleLineEdit(new LineRange(startLineNumber, endLineNumberEx), newLines);
265+
return new LineReplacement(new LineRange(startLineNumber, endLineNumberEx), newLines);
266266
}
267267

268268
constructor(
@@ -343,7 +343,7 @@ export class SingleLineEdit {
343343
];
344344
}
345345

346-
public removeCommonSuffixPrefixLines(initialValue: AbstractText): SingleLineEdit {
346+
public removeCommonSuffixPrefixLines(initialValue: AbstractText): LineReplacement {
347347
let startLineNumber = this.lineRange.startLineNumber;
348348
let endLineNumberEx = this.lineRange.endLineNumberExclusive;
349349

@@ -368,7 +368,7 @@ export class SingleLineEdit {
368368
if (trimStartCount === 0 && trimEndCount === 0) {
369369
return this;
370370
}
371-
return new SingleLineEdit(new LineRange(startLineNumber, endLineNumberEx), this.newLines.slice(trimStartCount, this.newLines.length - trimEndCount));
371+
return new LineReplacement(new LineRange(startLineNumber, endLineNumberEx), this.newLines.slice(trimStartCount, this.newLines.length - trimEndCount));
372372
}
373373

374374
public toLineEdit(): LineEdit {

src/vs/editor/contrib/inlineCompletions/browser/view/inlineEdits/inlineEditWithChanges.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { SingleLineEdit } from '../../../../../common/core/edits/lineEdit.js';
6+
import { LineReplacement } from '../../../../../common/core/edits/lineEdit.js';
77
import { LineRange } from '../../../../../common/core/ranges/lineRange.js';
88
import { Position } from '../../../../../common/core/position.js';
99
import { TextEdit } from '../../../../../common/core/edits/textEdit.js';
@@ -13,7 +13,7 @@ import { InlineSuggestionItem } from '../../model/inlineSuggestionItem.js';
1313

1414
export class InlineEditWithChanges {
1515
public get lineEdit() {
16-
return SingleLineEdit.fromSingleTextEdit(this.edit.toReplacement(this.originalText), this.originalText);
16+
return LineReplacement.fromSingleTextEdit(this.edit.toReplacement(this.originalText), this.originalText);
1717
}
1818

1919
public get originalLineRange() { return this.lineEdit.lineRange; }

0 commit comments

Comments
 (0)