Skip to content

add filterFontDecoration to decorationProvider#289146

Merged
aiday-mar merged 1 commit intomainfrom
scientific-swallow
Jan 20, 2026
Merged

add filterFontDecoration to decorationProvider#289146
aiday-mar merged 1 commit intomainfrom
scientific-swallow

Conversation

@aiday-mar
Copy link
Contributor

fixes #289140

Copilot AI review requested due to automatic review settings January 20, 2026 16:10
@aiday-mar aiday-mar self-assigned this Jan 20, 2026
@aiday-mar aiday-mar marked this pull request as ready for review January 20, 2026 16:11
@aiday-mar aiday-mar enabled auto-merge (squash) January 20, 2026 16:11
@vs-code-engineering vs-code-engineering bot added this to the January 2026 milestone Jan 20, 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

Adds support for filtering out font-affecting decorations when collecting decorations from DecorationProviders, addressing the reported issue.

Changes:

  • Extends DecorationProvider APIs to accept filterFontDecorations (and updates some call sites).
  • Passes filterFontDecorations through TextModel when querying provider decorations in a range.
  • Updates the tokenization font decoration provider to skip font-affecting decorations when requested.

Reviewed changes

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

File Description
src/vs/editor/common/model/tokens/tokenizationFontDecorationsProvider.ts Adds filterFontDecorations support when returning tokenization font decorations in a range.
src/vs/editor/common/model/textModel.ts For range-based decoration queries, forwards filterFontDecorations to decoration providers.
src/vs/editor/common/model/decorationProvider.ts Extends the DecorationProvider interface to include filterFontDecorations (and onlyMinimapDecorations for getAllDecorations).
src/vs/editor/common/model/bracketPairsTextModelPart/colorizedBracketPairsDecorationProvider.ts Updates provider method signatures to accept filterFontDecorations and forwards it through getAllDecorations.

Comment on lines +130 to +134
if (!(affectsFont && filterFontDecorations)) {
const annotationStartPosition = this.textModel.getPositionAt(annotation.range.start);
const annotationEndPosition = this.textModel.getPositionAt(annotation.range.endExclusive);
const range = Range.fromPositions(annotationStartPosition, annotationEndPosition);
const anno = annotation.annotation;
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

getDecorationsInRange now filters via filterFontDecorations, but the implementation duplicates annotation.annotation (anno) and uses a double-negative condition (if (!(affectsFont && filterFontDecorations))), which makes the logic harder to follow and easy to regress. Consider computing anno once and rewriting the guard as if (!filterFontDecorations || !affectsFont) to avoid shadowing and improve readability.

Suggested change
if (!(affectsFont && filterFontDecorations)) {
const annotationStartPosition = this.textModel.getPositionAt(annotation.range.start);
const annotationEndPosition = this.textModel.getPositionAt(annotation.range.endExclusive);
const range = Range.fromPositions(annotationStartPosition, annotationEndPosition);
const anno = annotation.annotation;
if (!filterFontDecorations || !affectsFont) {
const annotationStartPosition = this.textModel.getPositionAt(annotation.range.start);
const annotationEndPosition = this.textModel.getPositionAt(annotation.range.endExclusive);
const range = Range.fromPositions(annotationStartPosition, annotationEndPosition);

Copilot uses AI. Check for mistakes.
* @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
*/
getAllDecorations(ownerId?: number, filterOutValidation?: boolean, onlyMinimapDecorations?: boolean): IModelDecoration[];
getAllDecorations(ownerId?: number, filterOutValidation?: boolean, filterFontDecorations?: boolean, onlyMinimapDecorations?: boolean): IModelDecoration[];
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

DecorationProvider.getAllDecorations now exposes filterFontDecorations (and onlyMinimapDecorations), but TextModel.getAllDecorations(...) currently does not forward filterFontDecorations to _decorationProvider.getAllDecorations / _fontTokenDecorationsProvider.getAllDecorations, and at least TokenizationFontDecorationProvider.getAllDecorations still ignores the new flag. This makes filterFontDecorations behavior inconsistent between “range” and “all” queries. Either (a) update all implementers + TextModel aggregation to accept/forward these new params, or (b) avoid adding the params to the interface if they aren’t intended to be supported.

Suggested change
getAllDecorations(ownerId?: number, filterOutValidation?: boolean, filterFontDecorations?: boolean, onlyMinimapDecorations?: boolean): IModelDecoration[];
getAllDecorations(ownerId?: number, filterOutValidation?: boolean): IModelDecoration[];

Copilot uses AI. Check for mistakes.
@aiday-mar aiday-mar merged commit 1e99235 into main Jan 20, 2026
27 of 28 checks passed
@aiday-mar aiday-mar deleted the scientific-swallow branch January 20, 2026 16:42
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.

Custom line height not applied when opening files in diff editor

3 participants