textChange.ts ×18

Frontier kind: Code frontier

unlabeled · c_137662768b35

10 tests · 5693 LOC · 30 files · introduces 0 tests · 73 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
18 ranges73 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
859 ranges5693 lines · 30 files · Browse complete extent
All tests (intent)
10 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 specializationtextModel.ts ×6 · 31 introduced LOCtextModel.ts ×6textChange.ts ×1 · 4 introduced LOCtextChange.ts ×1textChange.test|title=TextChangeCompressor gen4|occurrence=1 · 0 introduced LOCtextChange.test|title=Te…textChange.test|title=TextChangeCompressor gen5|occurrence=1 · 0 introduced LOCtextChange.test|title=Te…textChange.ts ×1 · 6 introduced LOCtextChange.ts ×1textChange.test|title=TextChangeCompressor gen1|occurrence=1 · 0 introduced LOCtextChange.test|title=Te…textChange.ts ×1 · 5 introduced LOCtextChange.ts ×1textChange.test|title=TextChangeCompressor gen2|occurrence=1 · 0 introduced LOCtextChange.test|title=Te…textChange.test|title=TextChangeCompressor gen3|occurrence=1 · 0 introduced LOCtextChange.test|title=Te…textChange.ts ×1 · 4 introduced LOCtextChange.ts ×1textChange.test|title=TextChangeCompressor gen6|occurrence=1 · 0 introduced LOCtextChange.test|title=Te…textChange.ts ×1 · 1 introduced LOCtextChange.ts ×1textChange.ts ×1 · 5 introduced LOCtextChange.ts ×1textChange.ts ×1 · 18 introduced LOCtextChange.ts ×1textChange.test|title=TextChangeCompressor simple 1|occurrence=1 · 0 introduced LOCtextChange.test|title=Te…textChange.test|title=TextChangeCompressor simple 2|occurrence=1 · 0 introduced LOCtextChange.test|title=Te…textChange.ts ×1 · 4 introduced LOCtextChange.ts ×1textChange.ts ×1 · 5 introduced LOCtextChange.ts ×1textChange.ts ×1 · 3 introduced LOCtextChange.ts ×1textChange.ts ×4 · 20 introduced LOCtextChange.ts ×4textChange.ts ×1 · 4 introduced LOCtextChange.ts ×1textChange.ts ×1 · 18 introduced LOCtextChange.ts ×1textChange.ts ×1 · 4 introduced LOCtextChange.ts ×1textChange.ts ×1 · 2 introduced LOCtextChange.ts ×1textChange.ts ×2 · 10 introduced LOCtextChange.ts ×2textChange.ts ×2 · 10 introduced LOCtextChange.ts ×2textChange.ts ×1 · 7 introduced LOCtextChange.ts ×1textChange.ts ×1 · 2 introduced LOCtextChange.ts ×1textChange.ts ×1 · 1 introduced LOCtextChange.ts ×1textChange.ts ×1 · 5 introduced LOCtextChange.ts ×1textChange.ts ×26 · 78 introduced LOCtextChange.ts ×26stringBuilder.ts ×14 · 49 introduced LOCstringBuilder.ts ×14strings.test|title=Strings trimWhitespace|occurrence=1 · 0 introduced LOCstrings.test|title=Strin…strings.ts ×101 · 542 introduced LOCstrings.ts ×101cancellation.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 ×93buffer.ts ×42 · 483 introduced LOCbuffer.ts ×42uri.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…utils.ts ×3 · 9 introduced LOCutils.ts ×3linkedList.ts ×13 · 44 introduced LOClinkedList.ts ×13lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.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 ×1uint.ts ×2 · 43 introduced LOCuint.ts ×2lifecycle.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/buffer.ts · 499 LOCcommon/buffer.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/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/stream.ts · 790 LOCcommon/stream.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/stringBuilder.ts · 146 LOCcore/stringBuilder.tssrc/vs/editor/common/core/textChange.ts · 346 LOCcore/textChange.tssrc/vs/editor/common/model/editStack.ts · 451 LOCmodel/editStack.tssrc/vs/editor/common/model/intervalTree.ts · 1281 LOCmodel/intervalTree.tssrc/vs/editor/common/model/textModel.ts · 2743 LOCmodel/textModel.tssrc/vs/editor/common/textModelEvents.ts · 594 LOCcommon/textModelEvents.t…src/vs/nls.ts · 244 LOCvs/nls.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…modelInjectedText.test|title=Editor Model - Injected Text Events Basic|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/modelInjectedText.test|title=Editor Model - Injected Text Events Basic|occurrence=1modelInjectedText.test|t…textChange.test|title=TextChangeCompressor complex1|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/textChange.test|title=TextChangeCompressor complex1|occurrence=1textChange.test|title=Te…textChange.test|title=TextChangeCompressor gen1|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/textChange.test|title=TextChangeCompressor gen1|occurrence=1textChange.test|title=Te…textChange.test|title=TextChangeCompressor gen2|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/textChange.test|title=TextChangeCompressor gen2|occurrence=1textChange.test|title=Te…textChange.test|title=TextChangeCompressor gen3|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/textChange.test|title=TextChangeCompressor gen3|occurrence=1textChange.test|title=Te…textChange.test|title=TextChangeCompressor gen4|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/textChange.test|title=TextChangeCompressor gen4|occurrence=1textChange.test|title=Te…textChange.test|title=TextChangeCompressor gen5|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/textChange.test|title=TextChangeCompressor gen5|occurrence=1textChange.test|title=Te…textChange.test|title=TextChangeCompressor gen6|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/textChange.test|title=TextChangeCompressor gen6|occurrence=1textChange.test|title=Te…textChange.test|title=TextChangeCompressor simple 1|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/textChange.test|title=TextChangeCompressor simple 1|occurrence=1textChange.test|title=Te…textChange.test|title=TextChangeCompressor simple 2|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/model/textChange.test|title=TextChangeCompressor simple 2|occurrence=1textChange.test|title=Te…Focused concept · textChange.ts ×18 · 73 introduced LOCtextChange.ts ×18

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.

1 file ranked by introduced lines: 73 introduced LOC across 18 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/core/textChange.ts 73 introduced LOC · 18 ranges

Open complete file

22
23 public get oldEnd(): number {
24 > return this.oldPosition + this.oldText.length; textChange.ts
25 > }
26
27 public get newLength(): number {
28 > return this.newText.length; textChange.ts
29 > }
30
31 public get newEnd(): number {
101 return currEdits;
102 }
103 > const compressor = new TextChangeCompressor(prevEdits, currEdits); textChange.ts
104 > return compressor.compress();
105 > }
106
107 class TextChangeCompressor {
120
121 constructor(prevEdits: TextChange[], currEdits: TextChange[]) {
122 > this._prevEdits = prevEdits; textChange.ts
123 > this._currEdits = currEdits;
124 >
125 > this._result = [];
126 > this._resultLen = 0;
127 >
128 > this._prevLen = this._prevEdits.length;
129 > this._prevDeltaOffset = 0;
130 >
131 > this._currLen = this._currEdits.length;
132 > this._currDeltaOffset = 0;
133 > }
134
135 public compress(): TextChange[] {
136 > let prevIndex = 0; textChange.ts
137 > let currIndex = 0;
138 >
139 > let prevEdit = this._getPrev(prevIndex);
140 > let currEdit = this._getCurr(currIndex);
141 >
142 > while (prevIndex < this._prevLen || currIndex < this._currLen) {
143 >
144 > if (prevEdit === null) {
145 this._acceptCurr(currEdit!);
146 currEdit = this._getCurr(++currIndex);
147 continue;
148 }
150 > if (currEdit === null) {
151 this._acceptPrev(prevEdit);
152 prevEdit = this._getPrev(++prevIndex);
153 continue;
154 }
156 > if (currEdit.oldEnd <= prevEdit.newPosition) {
157 this._acceptCurr(currEdit);
158 currEdit = this._getCurr(++currIndex);
159 continue;
160 }
162 > if (prevEdit.newEnd <= currEdit.oldPosition) {
163 this._acceptPrev(prevEdit);
164 prevEdit = this._getPrev(++prevIndex);
213 this._currDeltaOffset += mergeCurr.newLength - mergeCurr.oldLength;
214 }
216 > const merged = TextChangeCompressor._merge(this._result);
217 > const cleaned = TextChangeCompressor._removeNoOps(merged);
218 > return cleaned;
219 > }
220
221 private _acceptCurr(currEdit: TextChange): void {
225
226 private _getCurr(currIndex: number): TextChange | null {
227 > return (currIndex < this._currLen ? this._currEdits[currIndex] : null); textChange.ts
228 > }
229
230 private _acceptPrev(prevEdit: TextChange): void {
234
235 private _getPrev(prevIndex: number): TextChange | null {
236 > return (prevIndex < this._prevLen ? this._prevEdits[prevIndex] : null); textChange.ts
237 > }
238
239 private static _rebaseCurr(prevDeltaOffset: number, currEdit: TextChange): TextChange {
296
297 private static _merge(edits: TextChange[]): TextChange[] {
298 > if (edits.length === 0) { textChange.ts
299 return edits;
300 }
302 > const result: TextChange[] = [];
303 > let resultLen = 0;
304 >
305 > let prev = edits[0];
306 > for (let i = 1; i < edits.length; i++) {
307 > const curr = edits[i];
308 >
309 > if (prev.oldEnd === curr.oldPosition) {
310 // Merge into `prev`
311 prev = new TextChange(
315 prev.newText + curr.newText
316 );
317 > } else { textChange.ts
318 result[resultLen++] = prev;
319 prev = curr;
320 }
321 > } textChange.ts
322 > result[resultLen++] = prev;
323 >
324 > return result;
325 > }
326
327 private static _removeNoOps(edits: TextChange[]): TextChange[] {
328 > if (edits.length === 0) { textChange.ts
329 return edits;
330 }
332 > const result: TextChange[] = [];
333 > let resultLen = 0;
334 >
335 > for (let i = 0; i < edits.length; i++) {
336 > const edit = edits[i];
337 >
338 > if (edit.oldText === edit.newText) {
339 continue;
340 }
341 > result[resultLen++] = edit; textChange.ts
342 > }
343 >
344 > return result;
345 > }
346 }