sparseMultilineTokens.ts ×11

Frontier kind: Code frontier

unlabeled · c_b8f19c9f0aa7

2 tests · 42163 LOC · 240 files · introduces 0 tests · 65 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges65 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5374 ranges42163 lines · 240 files · Browse complete extent
All tests (intent)
2 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: 65 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/tokens/sparseMultilineTokens.ts 65 introduced LOC · 11 ranges

Open complete file

103 private _acceptDeleteRange(range: IRange): void {
104 if (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn) {
105 > // Nothing to delete sparseMultilineTokens.ts
106 > return;
107 > }
108
109 const firstLineIndex = range.startLineNumber - this._startLineNumber;
147 return;
148 }
150 > const lineIndex = position.lineNumber - this._startLineNumber;
151 >
152 > if (lineIndex < 0) {
153 // this insertion occurs before this block, so we only need to adjust line numbers
154 this._startLineNumber += eolCount;
155 return;
156 }
158 > const tokenMaxDeltaLine = this._tokens.getMaxDeltaLine();
159 >
160 > if (lineIndex >= tokenMaxDeltaLine + 1) {
161 // this insertion occurs after this block, so there is nothing to do
162 return;
163 }
165 > this._tokens.acceptInsertText(lineIndex, position.column - 1, eolCount, firstLineLength, lastLineLength, firstCharCode);
166 }
167
485
486 public acceptInsertText(deltaLine: number, character: number, eolCount: number, firstLineLength: number, lastLineLength: number, firstCharCode: number): void {
487 > // Here are the cases I used to think about this: sparseMultilineTokens.ts
488 > //
489 > // 1. The token is completely before the insertion point
490 > // ----------- |
491 > // 2. The token ends precisely at the insertion point
492 > // -----------|
493 > // 3. The token contains the insertion point
494 > // -----|------
495 > // 4. The token starts precisely at the insertion point
496 > // |-----------
497 > // 5. The token is completely after the insertion point
498 > // | -----------
499 > //
500 > const isInsertingPreciselyOneWordCharacter = (
501 > eolCount === 0
502 && firstLineLength === 1
503 && (
505 || (firstCharCode >= CharCode.A && firstCharCode <= CharCode.Z)
506 || (firstCharCode >= CharCode.a && firstCharCode <= CharCode.z)
508 > );
509 > const tokens = this._tokens;
510 > const tokenCount = this._tokenCount;
511 > for (let i = 0; i < tokenCount; i++) {
512 > const offset = 4 * i;
513 > let tokenDeltaLine = tokens[offset];
514 > let tokenStartCharacter = tokens[offset + 1];
515 > let tokenEndCharacter = tokens[offset + 2];
516 >
517 > if (tokenDeltaLine < deltaLine || (tokenDeltaLine === deltaLine && tokenEndCharacter < character)) {
518 > // 1. The token is completely before the insertion point
519 > // => nothing to do
520 > continue;
521 > } else if (tokenDeltaLine === deltaLine && tokenEndCharacter === character) {
522 // 2. The token ends precisely at the insertion point
523 // => expand the end character only if inserting precisely one character that is a word character
527 continue;
528 }
529 > } else if (tokenDeltaLine === deltaLine && tokenStartCharacter < character && character < tokenEndCharacter) { sparseMultilineTokens.ts
530 // 3. The token contains the insertion point
531 if (eolCount === 0) {
536 tokenEndCharacter = character;
537 }
538 > } else { sparseMultilineTokens.ts
539 > // 4. or 5.
540 > if (tokenDeltaLine === deltaLine && tokenStartCharacter === character) {
541 // 4. The token starts precisely at the insertion point
542 // => grow the token (by keeping its start constant) only if inserting precisely one character that is a word character
546 }
547 }
548 > // => the token must move and keep its size constant sparseMultilineTokens.ts
549 > if (tokenDeltaLine === deltaLine) {
550 > tokenDeltaLine += eolCount;
551 > // this token is on the line where the insertion is taking place
552 > if (eolCount === 0) {
553 tokenStartCharacter += firstLineLength;
554 tokenEndCharacter += firstLineLength;
555 > } else { sparseMultilineTokens.ts
556 > const tokenLength = tokenEndCharacter - tokenStartCharacter;
557 > tokenStartCharacter = lastLineLength + (tokenStartCharacter - character);
558 > tokenEndCharacter = tokenStartCharacter + tokenLength;
559 > }
560 > } else {
561 tokenDeltaLine += eolCount;
562 }
564 >
565 > tokens[offset] = tokenDeltaLine;
566 > tokens[offset + 1] = tokenStartCharacter;
567 > tokens[offset + 2] = tokenEndCharacter;
568 > }
569 > }
570
571 private static _rateLimiter = new RateLimiter(10 / 60); // limit to 10 times per minute