Skip to content

Reaching out to next annotation when boundaries equal#292875

Merged
aiday-mar merged 3 commits intomainfrom
pleasant-turkey
Feb 4, 2026
Merged

Reaching out to next annotation when boundaries equal#292875
aiday-mar merged 3 commits intomainfrom
pleasant-turkey

Conversation

@aiday-mar
Copy link
Contributor

@aiday-mar aiday-mar commented Feb 4, 2026

fixes #292820

Copilot AI review requested due to automatic review settings February 4, 2026 16:59
@aiday-mar aiday-mar self-assigned this Feb 4, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts how annotated string intersections are computed (especially at empty/cursor positions) and updates font tokenization decorations to better handle multi-line ranges, with an additional unit test to cover the new intersection behavior.

Changes:

  • Extend AnnotatedString.getAnnotationsIntersecting to treat empty ranges as cursor positions that pick up annotations starting at that offset, and add a corresponding unit test.
  • Update TokenizationFontDecorationProvider to map font token annotations across their full line span (from start to end line) when adding and clearing line height/font decorations.
  • Introduce extensive debug console.log instrumentation in the annotation and font decoration code paths (these should be removed before merge).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/vs/editor/test/common/model/annotations.test.ts Adds getAnnotationsIntersecting 6 test to validate that an empty OffsetRange at a boundary returns only the annotation starting at that offset.
src/vs/editor/common/model/tokens/tokenizationFontDecorationsProvider.ts Expands font token decoration updates to operate across all lines covered by an annotation, but also adds multiple console.log calls in the hot path.
src/vs/editor/common/model/tokens/annotations.ts Documents and adjusts intersection behavior for empty ranges and modifies _getEndIndexOfIntersectingAnnotation, while adding debug console.log statements to the core indexing routine.

Comment on lines 49 to 50
console.log('fontChanges : ', JSON.stringify(fontChanges));

Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug logging with console.log inside this hot path will run for every font tokenization update, which can significantly degrade performance and spam the console in normal editor usage. Please remove these console.log calls (or replace them with an appropriate tracing mechanism behind a debug flag) before merging.

Copilot uses AI. Check for mistakes.
Comment on lines 104 to 110
console.log('endIndexWhereToReplace >= 0');
console.log('endIndexWhereToReplace : ', endIndexWhereToReplace);
console.log('offset : ', offset);
endIndexExclusive = endIndexWhereToReplace + 1;
// Also include the next annotation if it starts exactly at offset (touching boundary)
const nextCandidate = this._annotations[endIndexExclusive]?.range;
console.log('nextCandidate : ', JSON.stringify(nextCandidate));
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These console.log statements in the core annotation index calculation are leftover debug logs and will execute on every intersection query, adding unnecessary overhead and noisy output. They should be removed (or gated behind a proper debug/tracing facility) so that _getEndIndexOfIntersectingAnnotation remains side-effect free and efficient.

Suggested change
console.log('endIndexWhereToReplace >= 0');
console.log('endIndexWhereToReplace : ', endIndexWhereToReplace);
console.log('offset : ', offset);
endIndexExclusive = endIndexWhereToReplace + 1;
// Also include the next annotation if it starts exactly at offset (touching boundary)
const nextCandidate = this._annotations[endIndexExclusive]?.range;
console.log('nextCandidate : ', JSON.stringify(nextCandidate));
endIndexExclusive = endIndexWhereToReplace + 1;
// Also include the next annotation if it starts exactly at offset (touching boundary)
const nextCandidate = this._annotations[endIndexExclusive]?.range;

Copilot uses AI. Check for mistakes.
Comment on lines 104 to 110
console.log('endIndexWhereToReplace >= 0');
console.log('endIndexWhereToReplace : ', endIndexWhereToReplace);
console.log('offset : ', offset);
endIndexExclusive = endIndexWhereToReplace + 1;
// Also include the next annotation if it starts exactly at offset (touching boundary)
const nextCandidate = this._annotations[endIndexExclusive]?.range;
console.log('nextCandidate : ', JSON.stringify(nextCandidate));
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up to the previous comment: this additional console.log for nextCandidate should also be removed along with the other debug logging around _getEndIndexOfIntersectingAnnotation. Keeping this helper free of logging avoids polluting the console during normal editor operation.

Suggested change
console.log('endIndexWhereToReplace >= 0');
console.log('endIndexWhereToReplace : ', endIndexWhereToReplace);
console.log('offset : ', offset);
endIndexExclusive = endIndexWhereToReplace + 1;
// Also include the next annotation if it starts exactly at offset (touching boundary)
const nextCandidate = this._annotations[endIndexExclusive]?.range;
console.log('nextCandidate : ', JSON.stringify(nextCandidate));
endIndexExclusive = endIndexWhereToReplace + 1;
// Also include the next annotation if it starts exactly at offset (touching boundary)
const nextCandidate = this._annotations[endIndexExclusive]?.range;

Copilot uses AI. Check for mistakes.
const startLineNumber = startPosition.lineNumber;
const endPosition = this.textModel.getPositionAt(annotation.range.endExclusive);
const endLineNumber = endPosition.lineNumber;
console.log('annotation range : ', annotation.range.start, annotation.range.endExclusive, ' startLineNumber : ', startLineNumber, ' endLineNumber : ', endLineNumber);
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This console.log for the annotation range will fire on every font token change and should be removed (or converted to a proper trace facility) before shipping; otherwise it will add noise and cost in normal editor sessions.

Copilot uses AI. Check for mistakes.
Comment on lines 88 to 95
console.log('lineNumber changed : ', lineNumber);
// Signal the removal of the font tokenization decorations on the line number
const lineNumberStartOffset = this.textModel.getOffsetAt(new Position(lineNumber, 1));
const lineNumberEndOffset = this.textModel.getOffsetAt(new Position(lineNumber, this.textModel.getLineMaxColumn(lineNumber)));
const lineOffsetRange = new OffsetRange(lineNumberStartOffset, lineNumberEndOffset);
const lineAnnotations = this._fontAnnotatedString.getAnnotationsIntersecting(lineOffsetRange);
console.log('this._fontAnnotatedString : ', JSON.stringify(this._fontAnnotatedString));
console.log('lineOffsetRange : ', JSON.stringify(lineOffsetRange));
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These console.log statements inside the per-line loop will run once per affected line and can be extremely noisy and slow when many lines are re-tokenized. Please drop these debug logs or guard them behind an explicit debug flag to avoid impacting normal usage.

Copilot uses AI. Check for mistakes.
}
}
this._fontAnnotatedString.setAnnotations(AnnotationsUpdate.create(fontTokenAnnotations));
console.log('affectedLineHeights : ', JSON.stringify([...affectedLineHeights]));
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This final console.log of affectedLineHeights is also debug-only and should be removed to keep the decoration provider free of side-effectful logging in production.

Suggested change
console.log('affectedLineHeights : ', JSON.stringify([...affectedLineHeights]));

Copilot uses AI. Check for mistakes.
@aiday-mar aiday-mar changed the title adding code Reaching out to next annotation when boundaries equal Feb 4, 2026
@aiday-mar aiday-mar marked this pull request as ready for review February 4, 2026 18:27
@aiday-mar aiday-mar enabled auto-merge (squash) February 4, 2026 18:27
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 4, 2026
@aiday-mar aiday-mar merged commit dbd2e69 into main Feb 4, 2026
22 checks passed
@aiday-mar aiday-mar deleted the pleasant-turkey branch February 4, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing the font token customization settings leave certain lines with incorrect line height

3 participants