textEdit.ts ×8

Frontier kind: Code frontier

unlabeled · c_6ed97ff59aaa

97 tests · 6793 LOC · 38 files · introduces 0 tests · 90 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges90 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1170 ranges6793 lines · 38 files · Browse complete extent
All tests (intent)
97 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.

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: 90 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/core/edits/textEdit.ts 90 introduced LOC · 8 ranges

Open complete file

221 if (edits1.replacements.length === 0) { return edits2; }
222 if (edits2.replacements.length === 0) { return edits1; }
223 > textEdit.ts
224 > const resultReplacements: TextReplacement[] = [];
225 >
226 > let edit1Idx = 0;
227 > let lastEdit1EndS0Line = 1;
228 > let lastEdit1EndS0Col = 1;
229 >
230 > let headSrcRangeStartLine = 0;
231 > let headSrcRangeStartCol = 0;
232 > let headSrcRangeEndLine = 0;
233 > let headSrcRangeEndCol = 0;
234 > let headText: string | null = null;
235 > let headLengthLine = 0;
236 > let headLengthCol = 0;
237 >
238 > let headHasValue = false;
239 > let headIsInfinite = false;
240 >
241 > let currentPosInS1Line = 1;
242 > let currentPosInS1Col = 1;
243 >
244 > function ensureHead() {
245 > if (headHasValue) { return; }
246 >
247 > if (edit1Idx < edits1.replacements.length) {
248 > const nextEdit = edits1.replacements[edit1Idx];
249 > const nextEditStart = nextEdit.range.getStartPosition();
250 >
251 > const gapIsEmpty = (lastEdit1EndS0Line === nextEditStart.lineNumber) && (lastEdit1EndS0Col === nextEditStart.column);
252 >
253 > if (!gapIsEmpty) {
254 headSrcRangeStartLine = lastEdit1EndS0Line;
255 headSrcRangeStartCol = lastEdit1EndS0Col;
270 lastEdit1EndS0Line = nextEditStart.lineNumber;
271 lastEdit1EndS0Col = nextEditStart.column;
272 > } else { textEdit.ts
273 > const nextEditEnd = nextEdit.range.getEndPosition();
274 > headSrcRangeStartLine = nextEditStart.lineNumber;
275 > headSrcRangeStartCol = nextEditStart.column;
276 > headSrcRangeEndLine = nextEditEnd.lineNumber;
277 > headSrcRangeEndCol = nextEditEnd.column;
278 >
279 > headText = nextEdit.text;
280 >
281 > let line = 0;
282 > let column = 0;
283 > const text = nextEdit.text;
284 > for (let i = 0; i < text.length; i++) {
285 if (text.charCodeAt(i) === 10) {
286 line++;
290 }
291 }
292 > headLengthLine = line; textEdit.ts
293 > headLengthCol = column;
294 >
295 > headHasValue = true;
296 > lastEdit1EndS0Line = nextEditEnd.lineNumber;
297 > lastEdit1EndS0Col = nextEditEnd.column;
298 > edit1Idx++;
299 > }
300 > } else {
301 > headIsInfinite = true;
302 > headSrcRangeStartLine = lastEdit1EndS0Line;
303 > headSrcRangeStartCol = lastEdit1EndS0Col;
304 > headHasValue = true;
305 > }
306 > }
307 >
308 > function splitText(text: string, lenLine: number, lenCol: number): [string, string] {
309 if (lenLine === 0 && lenCol === 0) { return ['', text]; }
310 let line = 0;
319 return [text.substring(0, offset), text.substring(offset)];
320 }
321 > textEdit.ts
322 > for (const r2 of edits2.replacements) {
323 > const r2Start = r2.range.getStartPosition();
324 > const r2End = r2.range.getEndPosition();
325 >
326 > while (true) {
327 > if (currentPosInS1Line === r2Start.lineNumber && currentPosInS1Col === r2Start.column) { break; }
328 ensureHead();
329
424 headHasValue = false;
425 }
426 > textEdit.ts
427 > let consumedStartS0Line: number | null = null;
428 > let consumedStartS0Col: number | null = null;
429 > let consumedEndS0Line: number | null = null;
430 > let consumedEndS0Col: number | null = null;
431 >
432 > while (true) {
433 > if (currentPosInS1Line === r2End.lineNumber && currentPosInS1Col === r2End.column) { break; }
434 > ensureHead();
435 >
436 > if (headIsInfinite) {
437 let distLine: number, distCol: number;
438 if (currentPosInS1Line === r2End.lineNumber) {
557 headHasValue = false;
558 }
559 > textEdit.ts
560 > if (consumedStartS0Line !== null) {
561 > resultReplacements.push(new TextReplacement(new Range(consumedStartS0Line, consumedStartS0Col!, consumedEndS0Line!, consumedEndS0Col!), r2.text));
562 > } else {
563 ensureHead();
564 const insertPosS0Line = headSrcRangeStartLine;
566 resultReplacements.push(new TextReplacement(new Range(insertPosS0Line, insertPosS0Col, insertPosS0Line, insertPosS0Col), r2.text));
567 }
568 > } textEdit.ts
569 >
570 > while (true) {
571 > ensureHead();
572 > if (headIsInfinite) { break; }
573 if (headText !== null) {
574 resultReplacements.push(new TextReplacement(new Range(headSrcRangeStartLine, headSrcRangeStartCol, headSrcRangeEndLine, headSrcRangeEndCol), headText));
576 headHasValue = false;
577 }
578 > textEdit.ts
579 > return new TextEdit(resultReplacements).normalize();
580 }
581