stringEdit.ts ×9

Frontier kind: Code frontier

unlabeled · c_003d9f13d7df

4 tests · 7473 LOC · 40 files · introduces 0 tests · 238 LOC · 10 files

Introduces — evidence that enters the hierarchy at this concept

Code
31 ranges238 lines · 10 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1307 ranges7473 lines · 40 files · Browse complete extent
All tests (intent)
4 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationlineEdit.ts ×1 · 4 introduced LOClineEdit.ts ×1arcTracker.test|title=ArcTracker line-modification|occurrence=1 · 0 introduced LOCarcTracker.test|title=Ar…lineEdit.ts ×1 · 2 introduced LOClineEdit.ts ×1arcTracker.test|title=ArcTracker multiline-insert|occurrence=1 · 0 introduced LOCarcTracker.test|title=Ar…arcTracker.test|title=ArcTracker line-insert|occurrence=1 · 0 introduced LOCarcTracker.test|title=Ar…stringEdit.ts ×1 · 2 introduced LOCstringEdit.ts ×1stringEdit.ts ×1 · 4 introduced LOCstringEdit.ts ×1lineEdit.ts ×1 · 4 introduced LOClineEdit.ts ×1positionToOffsetImpl.ts ×1 · 1 introduced LOCpositionToOffsetImpl.ts …abstractText.ts ×4 · 16 introduced LOCabstractText.ts ×4lineEdit.ts ×27 · 95 introduced LOClineEdit.ts ×27positionToOffsetImpl.ts ×12 · 22 introduced LOCpositionToOffsetImpl.ts …positionToOffset.ts ×1 · 24 introduced LOCpositionToOffset.ts ×1edit.ts ×1 · 7 introduced LOCedit.ts ×1edit.ts ×2 · 3 introduced LOCedit.ts ×2edit.ts ×5 · 25 introduced LOCedit.ts ×5edit.ts ×1 · 2 introduced LOCedit.ts ×1edit.ts ×6 · 33 introduced LOCedit.ts ×6edit.ts ×1 · 1 introduced LOCedit.ts ×1edit.ts ×7 · 22 introduced LOCedit.ts ×7offsetRange.ts ×1 · 2 introduced LOCoffsetRange.ts ×1stringEdit.ts ×1 · 5 introduced LOCstringEdit.ts ×1edit.ts ×3 · 8 introduced LOCedit.ts ×3offsetRange.ts ×1 · 2 introduced LOCoffsetRange.ts ×1stringEdit.ts ×63 · 376 introduced LOCstringEdit.ts ×63textEdit.ts ×1 · 4 introduced LOCtextEdit.ts ×1abstractText.ts ×5 · 16 introduced LOCabstractText.ts ×5textEdit.ts ×1 · 4 introduced LOCtextEdit.ts ×1assert.ts ×2 · 4 introduced LOCassert.ts ×2textEdit.ts ×35 · 110 introduced LOCtextEdit.ts ×35abstractText.ts ×16 · 53 introduced LOCabstractText.ts ×16range.ts ×1 · 2 introduced LOCrange.ts ×1range.ts ×1 · 2 introduced LOCrange.ts ×1range.ts ×1 · 2 introduced LOCrange.ts ×1textLength.ts ×21 · 60 introduced LOCtextLength.ts ×21offsetRange.ts ×1 · 2 introduced LOCoffsetRange.ts ×1positionToOffsetImpl.ts ×6 · 25 introduced LOCpositionToOffsetImpl.ts …positionToOffsetImpl.ts ×19 · 71 introduced LOCpositionToOffsetImpl.ts …range.ts ×2 · 4 introduced LOCrange.ts ×2network.ts ×1 · 3 introduced LOCnetwork.ts ×1offsetRange.ts ×2 · 2 introduced LOCoffsetRange.ts ×2network.ts ×3 · 10 introduced LOCnetwork.ts ×3network.ts ×1 · 2 introduced LOCnetwork.ts ×1network.ts ×2 · 3 introduced LOCnetwork.ts ×2arrays.ts ×1 · 2 introduced LOCarrays.ts ×1network.ts ×20 · 292 introduced LOCnetwork.ts ×20strings.test|title=Strings trimWhitespace|occurrence=1 · 0 introduced LOCstrings.test|title=Strin…strings.ts ×1 · 2 introduced LOCstrings.ts ×1strings.ts ×101 · 542 introduced LOCstrings.ts ×101lineRange.ts ×1 · 2 introduced LOClineRange.ts ×1lineRange.ts ×2 · 7 introduced LOClineRange.ts ×2lineRange.ts ×40 · 148 introduced LOClineRange.ts ×40assert.ts ×2 · 2 introduced LOCassert.ts ×2cancellation.test|title=CancellationToken None|occurrence=1 · 0 introduced LOCcancellation.test|title=…cancellation.ts ×18 · 90 introduced LOCcancellation.ts ×18event.ts ×93 · 864 introduced LOCevent.ts ×93range.ts ×1 · 5 introduced LOCrange.ts ×1range.ts ×3 · 3 introduced LOCrange.ts ×3position.ts ×1 · 3 introduced LOCposition.ts ×1range.ts ×40 · 247 introduced LOCrange.ts ×40uri.ts ×3 · 8 introduced LOCuri.ts ×3offsetRange.ts ×40 · 132 introduced LOCoffsetRange.ts ×40uri.test|title=URI VSCode URI module's driveLetterPath regex is incorrect, #32961|occurrence=1 · 0 introduced LOCuri.test|title=URI VSCod…uri.ts ×2 · 3 introduced LOCuri.ts ×2uri.ts ×1 · 1 introduced LOCuri.ts ×1uri.ts ×1 · 1 introduced LOCuri.ts ×1uri.ts ×1 · 1 introduced LOCuri.ts ×1uri.ts ×1 · 2 introduced LOCuri.ts ×1uri.ts ×14 · 18 introduced LOCuri.ts ×14uri.ts ×1 · 1 introduced LOCuri.ts ×1uri.ts ×1 · 5 introduced LOCuri.ts ×1uri.ts ×1 · 3 introduced LOCuri.ts ×1uri.ts ×1 · 2 introduced LOCuri.ts ×1uri.ts ×6 · 10 introduced LOCuri.ts ×6path.ts ×3 · 28 introduced LOCpath.ts ×3position.ts ×16 · 113 introduced LOCposition.ts ×16uri.ts ×3 · 3 introduced LOCuri.ts ×3path.ts ×1 · 2 introduced LOCpath.ts ×1uri.ts ×3 · 3 introduced LOCuri.ts ×3uri.ts ×2 · 2 introduced LOCuri.ts ×2arraysFind.ts ×1 · 2 introduced LOCarraysFind.ts ×1uri.ts ×3 · 3 introduced LOCuri.ts ×3arraysFind.ts ×2 · 10 introduced LOCarraysFind.ts ×2assert.ts ×2 · 5 introduced LOCassert.ts ×2uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…uri.ts ×3 · 15 introduced LOCuri.ts ×3uri.ts ×2 · 10 introduced LOCuri.ts ×2utils.ts ×3 · 9 introduced LOCutils.ts ×3path.ts ×3 · 5 introduced LOCpath.ts ×3uri.ts ×1 · 2 introduced LOCuri.ts ×1uri.ts ×9 · 37 introduced LOCuri.ts ×9path.ts ×3 · 15 introduced LOCpath.ts ×3linkedList.ts ×13 · 44 introduced LOClinkedList.ts ×13path.ts ×1 · 2 introduced LOCpath.ts ×1path.ts ×3 · 10 introduced LOCpath.ts ×3path.ts ×3 · 14 introduced LOCpath.ts ×3lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2path.ts ×1 · 1 introduced LOCpath.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1path.ts ×6 · 24 introduced LOCpath.ts ×6lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lazy.ts ×1 · 2 introduced LOClazy.ts ×1lazy.ts ×3 · 37 introduced LOClazy.ts ×3lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1path.ts ×2 · 3 introduced LOCpath.ts ×2uint.ts ×2 · 43 introduced LOCuint.ts ×2arrays.ts ×1 · 2 introduced LOCarrays.ts ×1lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/cache.ts · 153 LOCcommon/cache.tssrc/vs/base/common/cancellation.ts · 206 LOCcommon/cancellation.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/event.ts · 1964 LOCcommon/event.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lazy.ts · 57 LOCcommon/lazy.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/linkedList.ts · 151 LOCcommon/linkedList.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/network.ts · 440 LOCcommon/network.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/stopwatch.ts · 41 LOCcommon/stopwatch.tssrc/vs/base/common/strings.ts · 1413 LOCcommon/strings.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uint.ts · 59 LOCcommon/uint.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/editor/common/core/edits/edit.ts · 398 LOCedits/edit.tssrc/vs/editor/common/core/edits/lineEdit.ts · 412 LOCedits/lineEdit.tssrc/vs/editor/common/core/edits/stringEdit.ts · 613 LOCedits/stringEdit.tssrc/vs/editor/common/core/edits/textEdit.ts · 784 LOCedits/textEdit.tssrc/vs/editor/common/core/position.ts · 184 LOCcore/position.tssrc/vs/editor/common/core/range.ts · 520 LOCcore/range.tssrc/vs/editor/common/core/ranges/lineRange.ts · 414 LOCranges/lineRange.tssrc/vs/editor/common/core/ranges/offsetRange.ts · 290 LOCranges/offsetRange.tssrc/vs/editor/common/core/text/abstractText.ts · 130 LOCtext/abstractText.tssrc/vs/editor/common/core/text/positionToOffset.ts · 24 LOCtext/positionToOffset.tssrc/vs/editor/common/core/text/positionToOffsetImpl.ts · 158 LOCtext/positionToOffsetImp…src/vs/editor/common/core/text/textLength.ts · 148 LOCtext/textLength.tssrc/vs/nls.ts · 244 LOCvs/nls.tssrc/vs/workbench/contrib/editTelemetry/common/arcTracker.ts · 89 LOCcommon/arcTracker.tscancellation.test|title=CancellationToken None|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/cancellation.test|title=CancellationToken None|occurrence=1cancellation.test|title=…charCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…strings.test|title=Strings trimWhitespace|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/strings.test|title=Strings trimWhitespace|occurrence=1strings.test|title=Strin…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…uri.test|title=URI VSCode URI module's driveLetterPath regex is incorrect, #32961|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI VSCode URI module's driveLetterPath regex is incorrect, #32961|occurrence=1uri.test|title=URI VSCod…arcTracker.test|title=ArcTracker issue-264048|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/editTelemetry/test/node/arcTracker.test|title=ArcTracker issue-264048|occurrence=1arcTracker.test|title=Ar…arcTracker.test|title=ArcTracker line-insert|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/editTelemetry/test/node/arcTracker.test|title=ArcTracker line-insert|occurrence=1arcTracker.test|title=Ar…arcTracker.test|title=ArcTracker line-modification|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/editTelemetry/test/node/arcTracker.test|title=ArcTracker line-modification|occurrence=1arcTracker.test|title=Ar…arcTracker.test|title=ArcTracker multiline-insert|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/editTelemetry/test/node/arcTracker.test|title=ArcTracker multiline-insert|occurrence=1arcTracker.test|title=Ar…Focused concept · stringEdit.ts ×9 · 238 introduced LOCstringEdit.ts ×9

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

10 files ranked by introduced lines: 238 introduced LOC across 31 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/workbench/contrib/editTelemetry/common/arcTracker.ts 76 introduced LOC · 4 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- arcTracker.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { sumBy } from '../../../../base/common/arrays.js';
7 > import { LineEdit } from '../../../../editor/common/core/edits/lineEdit.js';
8 > import { AnnotatedStringEdit, BaseStringEdit, IEditData } from '../../../../editor/common/core/edits/stringEdit.js';
9 > import { AbstractText } from '../../../../editor/common/core/text/abstractText.js';
10 >
11 > /**
12 > * The ARC (accepted and retained characters) counts how many characters inserted by the initial suggestion (trackedEdit)
13 > * stay unmodified after a certain amount of time after acceptance.
14 > */
15 > export class ArcTracker {
16 > private _updatedTrackedEdit: AnnotatedStringEdit<IsTrackedEditData>;
17 > private _trackedEdit: BaseStringEdit;
18 >
19 > constructor(
20 > private readonly _valueBeforeTrackedEdit: AbstractText,
21 > trackedEdit: BaseStringEdit,
22 > ) {
23 > this._trackedEdit = trackedEdit.removeCommonSuffixPrefix(_valueBeforeTrackedEdit.getValue());
24 > this._updatedTrackedEdit = this._trackedEdit.mapData(() => new IsTrackedEditData(true));
25 > }
26 >
27 > getOriginalCharacterCount(): number {
28 return sumBy(this._trackedEdit.replacements, e => e.getNewLength());
29 }
31 > /**
32 > * edit must apply to _updatedTrackedEdit.apply(_valueBeforeTrackedEdit)
33 > */
34 > handleEdits(edit: BaseStringEdit): void {
35 > const e = edit.mapData(_d => new IsTrackedEditData(false));
36 > const composedEdit = this._updatedTrackedEdit.compose(e); // (still) applies to _valueBeforeTrackedEdit
37 >
38 > // TODO@hediet improve memory by using:
39 > // composedEdit = const onlyTrackedEdit = composedEdit.decomposeSplit(e => !e.data.isTrackedEdit).e2;
40 >
41 > this._updatedTrackedEdit = composedEdit;
42 > }
43 >
44 > getAcceptedRestrainedCharactersCount(): number {
45 > const s = sumBy(this._updatedTrackedEdit.replacements, e => e.data.isTrackedEdit ? e.getNewLength() : 0);
46 > return s;
47 > }
48 >
49 > getDebugState(): unknown {
50 return {
51 edits: this._updatedTrackedEdit.replacements.map(e => ({
56 };
57 }
59 > public getLineCountInfo(): { deletedLineCounts: number; insertedLineCounts: number } {
60 > const e = this._updatedTrackedEdit.toStringEdit(r => r.data.isTrackedEdit);
61 > const le = LineEdit.fromStringEdit(e, this._valueBeforeTrackedEdit);
62 > const deletedLineCount = sumBy(le.replacements, r => r.lineRange.length);
63 > const insertedLineCount = sumBy(le.getNewLineRanges(), r => r.length);
64 > return {
65 > deletedLineCounts: deletedLineCount,
66 > insertedLineCounts: insertedLineCount,
67 > };
68 > }
69 >
70 > public getValues(): unknown {
71 > return {
72 > arc: this.getAcceptedRestrainedCharactersCount(),
73 > ...this.getLineCountInfo(),
74 > };
75 > }
76 > }
77 >
78 > export class IsTrackedEditData implements IEditData<IsTrackedEditData> {
79 > constructor(
80 > public readonly isTrackedEdit: boolean
81 > ) { }
82 >
83 > join(data: IsTrackedEditData): IsTrackedEditData | undefined {
84 > if (this.isTrackedEdit !== data.isTrackedEdit) {
85 return undefined;
86 }
87 return this;
88 > } arcTracker.ts
89 > }
src/vs/editor/common/core/edits/lineEdit.ts 73 introduced LOC · 8 ranges

Open complete file

22
23 public static fromStringEdit(edit: BaseStringEdit, initialValue: AbstractText): LineEdit {
24 > const textEdit = TextEdit.fromStringEdit(edit, initialValue); lineEdit.ts
25 > return LineEdit.fromTextEdit(textEdit, initialValue);
26 > }
27
28 public static fromTextEdit(edit: TextEdit, initialValue: AbstractText): LineEdit {
29 > const edits = edit.replacements; lineEdit.ts
30 >
31 > const result: LineReplacement[] = [];
32 >
33 > const currentEdits: TextReplacement[] = [];
34 > for (let i = 0; i < edits.length; i++) {
35 > const edit = edits[i];
36 > const nextEditRange = i + 1 < edits.length ? edits[i + 1] : undefined;
37 > currentEdits.push(edit);
38 > if (nextEditRange && nextEditRange.range.startLineNumber === edit.range.endLineNumber) {
39 continue;
40 }
42 > const singleEdit = TextReplacement.joinReplacements(currentEdits, initialValue);
43 > currentEdits.length = 0;
44 >
45 > const singleLineEdit = LineReplacement.fromSingleTextEdit(singleEdit, initialValue);
46 > result.push(singleLineEdit);
47 > }
48 >
49 > return new LineEdit(result);
50 > }
51
52 public static createFromUnsorted(edits: readonly LineReplacement[]): LineEdit {
87
88 public getNewLineRanges(): LineRange[] {
89 > const ranges: LineRange[] = []; lineEdit.ts
90 > let offset = 0;
91 > for (const e of this.replacements) {
92 > ranges.push(LineRange.ofLength(e.lineRange.startLineNumber + offset, e.newLines.length),);
93 > offset += e.newLines.length - e.lineRange.length;
94 > }
95 > return ranges;
96 > }
97
98 public mapLineNumber(lineNumber: number): number {
237
238 public static fromSingleTextEdit(edit: TextReplacement, initialValue: AbstractText): LineReplacement {
239 > // 1: ab[cde lineEdit.ts
240 > // 2: fghijk
241 > // 3: lmn]opq
242 >
243 > // replaced with
244 >
245 > // 1n: 123
246 > // 2n: 456
247 > // 3n: 789
248 >
249 > // simple solution: replace [1..4) with [1n..4n)
250 >
251 > const newLines = splitLines(edit.text);
252 > let startLineNumber = edit.range.startLineNumber;
253 > const survivingFirstLineText = initialValue.getValueOfRange(Range.fromPositions(
254 > new Position(edit.range.startLineNumber, 1),
255 > edit.range.getStartPosition()
256 > ));
257 > newLines[0] = survivingFirstLineText + newLines[0];
258 >
259 > let endLineNumberEx = edit.range.endLineNumber + 1;
260 > const editEndLineNumberMaxColumn = initialValue.getTransformer().getLineLength(edit.range.endLineNumber) + 1;
261 > const survivingEndLineText = initialValue.getValueOfRange(Range.fromPositions(
262 > edit.range.getEndPosition(),
263 > new Position(edit.range.endLineNumber, editEndLineNumberMaxColumn)
264 > ));
265 > newLines[newLines.length - 1] = newLines[newLines.length - 1] + survivingEndLineText;
266 >
267 > // Replacing [startLineNumber, endLineNumberEx) with newLines would be correct, however it might not be minimal.
268 >
269 > const startBeforeNewLine = edit.range.startColumn === initialValue.getTransformer().getLineLength(edit.range.startLineNumber) + 1;
270 > const endAfterNewLine = edit.range.endColumn === 1;
271 >
272 > if (startBeforeNewLine && newLines[0].length === survivingFirstLineText.length) {
273 // the replacement would not delete any text on the first line
274 startLineNumber++;
275 newLines.shift();
276 }
277 > lineEdit.ts
278 > if (newLines.length > 0 && startLineNumber < endLineNumberEx && endAfterNewLine && newLines[newLines.length - 1].length === survivingEndLineText.length) {
279 // the replacement would not delete any text on the last line
280 endLineNumberEx--;
281 newLines.pop();
282 }
283 > lineEdit.ts
284 > return new LineReplacement(new LineRange(startLineNumber, endLineNumberEx), newLines);
285 > }
286
287 constructor(
288 > public readonly lineRange: LineRange, lineEdit.ts
289 > public readonly newLines: readonly string[],
290 > ) { }
291
292 public toSingleTextEdit(initialValue: AbstractText): TextReplacement {
src/vs/editor/common/core/edits/stringEdit.ts 55 introduced LOC · 9 ranges

Open complete file

147
148 public removeCommonSuffixPrefix(originalText: string): StringEdit {
149 > const edits: StringReplacement[] = []; stringEdit.ts
150 > for (const e of this.replacements) {
151 > const edit = e.removeCommonSuffixPrefix(originalText);
152 > if (!edit.isEmpty) {
153 > edits.push(edit);
154 > }
155 > }
156 > return new StringEdit(edits);
157 > }
158
159 public normalizeEOL(eol: '\r\n' | '\n'): StringEdit {
184
185 public mapData<TData extends IEditData<TData>>(f: (replacement: T) => TData): AnnotatedStringEdit<TData> {
186 > return new AnnotatedStringEdit( stringEdit.ts
187 > this.replacements.map(e => new AnnotatedStringReplacement(
188 > e.replaceRange,
189 > e.newText,
190 > f(e)
191 > ))
192 > );
193 > }
194 }
195
221
222 removeCommonSuffixPrefix(originalText: string): StringReplacement {
223 > const oldText = originalText.substring(this.replaceRange.start, this.replaceRange.endExclusive); stringEdit.ts
224 >
225 > const prefixLen = commonPrefixLength(oldText, this.newText);
226 > const suffixLen = Math.min(
227 > oldText.length - prefixLen,
228 > this.newText.length - prefixLen,
229 > commonSuffixLength(oldText, this.newText)
230 > );
231 >
232 > const replaceRange = new OffsetRange(
233 > this.replaceRange.start + prefixLen,
234 > this.replaceRange.endExclusive - suffixLen,
235 > );
236 > const newText = this.newText.substring(prefixLen, this.newText.length - suffixLen);
237 >
238 > return new StringReplacement(replaceRange, newText);
239 > }
240
241 normalizeEOL(eol: '\r\n' | '\n'): StringReplacement {
544
545 protected override _createNew(replacements: readonly AnnotatedStringReplacement<T>[]): AnnotatedStringEdit<T> {
546 > return new AnnotatedStringEdit<T>(replacements); stringEdit.ts
547 > }
548
549 public toStringEdit(filter?: (replacement: AnnotatedStringReplacement<T>) => boolean): StringEdit {
550 > const newReplacements: StringReplacement[] = []; stringEdit.ts
551 > for (const r of this.replacements) {
552 > if (!filter || filter(r)) {
553 > newReplacements.push(new StringReplacement(r.replaceRange, r.newText));
554 > }
555 > }
556 > return new StringEdit(newReplacements);
557 > }
558 }
559
572
573 constructor(
574 > range: OffsetRange, stringEdit.ts
575 > newText: string,
576 > public readonly data: T
577 > ) {
578 > super(range, newText);
579 > }
580
581 override equals(other: AnnotatedStringReplacement<T>): boolean {
584
585 tryJoinTouching(other: AnnotatedStringReplacement<T>): AnnotatedStringReplacement<T> | undefined {
586 > const joined = this.data.join(other.data); stringEdit.ts
587 > if (joined === undefined) {
588 return undefined;
589 }
590 return new AnnotatedStringReplacement(this.replaceRange.joinRightTouching(other.replaceRange), this.newText + other.newText, joined);
591 > } stringEdit.ts
592
593 slice(range: OffsetRange, rangeInReplacement?: OffsetRange): AnnotatedStringReplacement<T> {
594 > return new AnnotatedStringReplacement(range, rangeInReplacement ? rangeInReplacement.substring(this.newText) : this.newText, this.data); stringEdit.ts
595 > }
596 }
597
src/vs/base/common/strings.ts 19 introduced LOC · 4 ranges

Open complete file

457 */
458 export function commonPrefixLength(a: string, b: string): number {
459 > strings.ts
460 > const len = Math.min(a.length, b.length);
461 > let i: number;
462 >
463 > for (i = 0; i < len; i++) {
464 if (a.charCodeAt(i) !== b.charCodeAt(i)) {
465 return i;
466 }
467 }
468 > strings.ts
469 > return len;
470 > }
471
472 /**
474 */
475 export function commonSuffixLength(a: string, b: string): number {
476 > strings.ts
477 > const len = Math.min(a.length, b.length);
478 > let i: number;
479 >
480 > const aLastIndex = a.length - 1;
481 > const bLastIndex = b.length - 1;
482 >
483 > for (i = 0; i < len; i++) {
484 if (a.charCodeAt(aLastIndex - i) !== b.charCodeAt(bLastIndex - i)) {
485 return i;
486 }
487 }
488 > strings.ts
489 > return len;
490 > }
491
492 /**
src/vs/editor/common/core/text/positionToOffsetImpl.ts 5 introduced LOC · 1 range

Open complete file

25
26 getRange(offsetRange: OffsetRange): Range {
27 > return Range.fromPositions( positionToOffsetImpl.ts
28 > this.getPosition(offsetRange.start),
29 > this.getPosition(offsetRange.endExclusive)
30 > );
31 > }
32
33 getStringEdit(edit: TextEdit): StringEdit {
src/vs/editor/common/core/edits/edit.ts 2 introduced LOC · 1 range

Open complete file

340
341 get isEmpty() {
342 > return this.getNewLength() === 0 && this.replaceRange.length === 0; edit.ts
343 > }
344
345 getRangeAfterReplace(): OffsetRange {
src/vs/editor/common/core/edits/textEdit.ts 2 introduced LOC · 1 range

Open complete file

667
668 public static fromStringReplacement(replacement: StringReplacement, initialState: AbstractText): TextReplacement {
669 > return new TextReplacement(initialState.getTransformer().getRange(replacement.replaceRange), replacement.newText); textEdit.ts
670 > }
671
672 public static delete(range: Range): TextReplacement {
src/vs/editor/common/core/ranges/lineRange.ts 2 introduced LOC · 1 range

Open complete file

15 export class LineRange {
16 public static ofLength(startLineNumber: number, length: number): LineRange {
17 > return new LineRange(startLineNumber, startLineNumber + length); lineRange.ts
18 > }
19
20 public static fromRange(range: IRange): LineRange {
src/vs/editor/common/core/text/abstractText.ts 2 introduced LOC · 1 range

Open complete file

126 // Override the getTransformer method to return the cached transformer
127 override getTransformer() {
128 > return this._t; abstractText.ts
129 > }
130 }
src/vs/editor/common/core/text/positionToOffset.ts 2 introduced LOC · 1 range

Open complete file

21 // TODO@hediet this is dept and needs to go. See https://github.com/microsoft/vscode/issues/251126.
22 export function ensureDependenciesAreSet(): void {
23 > // Noop positionToOffset.ts
24 > }