sparseMultilineTokens.ts ×9

Frontier kind: Code frontier

unlabeled · c_113a6ac2d5b0

4 tests · 41981 LOC · 240 files · introduces 0 tests · 74 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges74 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5309 ranges41981 lines · 240 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.

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

src/vs/editor/common/tokens/sparseMultilineTokens.ts 74 introduced LOC · 9 ranges

Open complete file

130 return;
131 }
133 > if (firstLineIndex < 0) {
134 const deletedBefore = -firstLineIndex;
135 this._startLineNumber -= deletedBefore;
136
137 this._tokens.acceptDeleteRange(range.startColumn - 1, 0, 0, lastLineIndex, range.endColumn - 1);
138 > } else { sparseMultilineTokens.ts
139 this._tokens.acceptDeleteRange(0, firstLineIndex, range.startColumn - 1, lastLineIndex, range.endColumn - 1);
140 }
352
353 public acceptDeleteRange(horizontalShiftForFirstLineTokens: number, startDeltaLine: number, startCharacter: number, endDeltaLine: number, endCharacter: number): void {
354 > // This is a bit complex, here are the cases I used to think about this: sparseMultilineTokens.ts
355 > //
356 > // 1. The token starts before the deletion range
357 > // 1a. The token is completely before the deletion range
358 > // -----------
359 > // xxxxxxxxxxx
360 > // 1b. The token starts before, the deletion range ends after the token
361 > // -----------
362 > // xxxxxxxxxxx
363 > // 1c. The token starts before, the deletion range ends precisely with the token
364 > // ---------------
365 > // xxxxxxxx
366 > // 1d. The token starts before, the deletion range is inside the token
367 > // ---------------
368 > // xxxxx
369 > //
370 > // 2. The token starts at the same position with the deletion range
371 > // 2a. The token starts at the same position, and ends inside the deletion range
372 > // -------
373 > // xxxxxxxxxxx
374 > // 2b. The token starts at the same position, and ends at the same position as the deletion range
375 > // ----------
376 > // xxxxxxxxxx
377 > // 2c. The token starts at the same position, and ends after the deletion range
378 > // -------------
379 > // xxxxxxx
380 > //
381 > // 3. The token starts inside the deletion range
382 > // 3a. The token is inside the deletion range
383 > // -------
384 > // xxxxxxxxxxxxx
385 > // 3b. The token starts inside the deletion range, and ends at the same position as the deletion range
386 > // ----------
387 > // xxxxxxxxxxxxx
388 > // 3c. The token starts inside the deletion range, and ends after the deletion range
389 > // ------------
390 > // xxxxxxxxxxx
391 > //
392 > // 4. The token starts after the deletion range
393 > // -----------
394 > // xxxxxxxx
395 > //
396 > const tokens = this._tokens;
397 > const tokenCount = this._tokenCount;
398 > const deletedLineCount = (endDeltaLine - startDeltaLine);
399 > let newTokenCount = 0;
400 > let hasDeletedTokens = false;
401 > for (let i = 0; i < tokenCount; i++) {
402 > const srcOffset = 4 * i;
403 > let tokenDeltaLine = tokens[srcOffset];
404 > let tokenStartCharacter = tokens[srcOffset + 1];
405 > let tokenEndCharacter = tokens[srcOffset + 2];
406 > const tokenMetadata = tokens[srcOffset + 3];
407 >
408 > if (tokenDeltaLine < startDeltaLine || (tokenDeltaLine === startDeltaLine && tokenEndCharacter <= startCharacter)) {
409 // 1a. The token is completely before the deletion range
410 // => nothing to do
411 newTokenCount++;
412 continue;
413 > } else if (tokenDeltaLine === startDeltaLine && tokenStartCharacter < startCharacter) { sparseMultilineTokens.ts
414 // 1b, 1c, 1d
415 // => the token survives, but it needs to shrink
424 tokenEndCharacter = startCharacter;
425 }
426 > } else if (tokenDeltaLine === startDeltaLine && tokenStartCharacter === startCharacter) { sparseMultilineTokens.ts
427 // 2a, 2b, 2c
428 if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) {
437 continue;
438 }
439 > } else if (tokenDeltaLine < endDeltaLine || (tokenDeltaLine === endDeltaLine && tokenStartCharacter < endCharacter)) { sparseMultilineTokens.ts
440 // 3a, 3b, 3c
441 if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) {
452 continue;
453 }
454 > } else if (tokenDeltaLine > endDeltaLine) { sparseMultilineTokens.ts
455 // 4. (partial) The token starts after the deletion range, on a line below...
456 if (deletedLineCount === 0 && !hasDeletedTokens) {
460 }
461 tokenDeltaLine -= deletedLineCount;
462 > } else if (tokenDeltaLine === endDeltaLine && tokenStartCharacter >= endCharacter) { sparseMultilineTokens.ts
463 // 4. (continued) The token starts after the deletion range, on the last line where a deletion occurs
464 if (horizontalShiftForFirstLineTokens && tokenDeltaLine === 0) {
472 throw new Error(`Not possible!`);
473 }
475 > const destOffset = 4 * newTokenCount;
476 > tokens[destOffset] = tokenDeltaLine;
477 > tokens[destOffset + 1] = tokenStartCharacter;
478 > tokens[destOffset + 2] = tokenEndCharacter;
479 > tokens[destOffset + 3] = tokenMetadata;
480 > newTokenCount++;
481 > }
482 >
483 > this._tokenCount = newTokenCount;
484 > }
485
486 public acceptInsertText(deltaLine: number, character: number, eolCount: number, firstLineLength: number, lastLineLength: number, firstCharCode: number): void {