352
353
public acceptDeleteRange(horizontalShiftForFirstLineTokens: number, startDeltaLine: number, startCharacter: number, endDeltaLine: number, endCharacter: number): void {
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;
414
// 1b, 1c, 1d
415
// => the token survives, but it needs to shrink