Repository: microsoft/vscode
File: src/vs/editor/common/model/tokens/tokenizationFontDecorationsProvider.ts (TypeScript)

Code before:
import { Disposable } from '../../../../base/common/lifecycle.js';
import { IModelDecoration, ITextModel } from '../../model.js';
import { TokenizationTextModelPart } from './tokenizationTextModelPart.js';
import { Range } from '../../core/range.js';
import { DecorationProvider, LineFontChangingDecoration, LineHeightMultiplierChangingDecoration } from '../decorationProvider.js';
import { Emitter } from '../../../../base/common/event.js';
import { IFontTokenOption, IModelContentChangedEvent } from '../../textModelEvents.js';
import { classNameForFontTokenDecorations } from '../../languages/supports/tokenization.js';
import { Position } from '../../core/position.js';
import { AnnotatedString, AnnotationsUpdate, IAnnotatedString, IAnnotationUpdate } from './annotations.js';
import { OffsetRange } from '../../core/ranges/offsetRange.js';
import { offsetEditFromContentChanges } from '../textModelStringEdit.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';

export interface IFontTokenAnnotation {
	decorationId: string;
	fontToken: IFontTokenOption;
}

export class TokenizationFontDecorationProvider extends Disposable implements DecorationProvider {

	private static DECORATION_COUNT = 0;

	private readonly _onDidChangeLineHeightMultiplier = new Emitter<Set<LineHeightMultiplierChangingDecoration>>();
	public readonly onDidChangeLineHeightMultiplier = this._onDidChangeLineHeightMultiplier.event;

	private readonly _onDidChangeFont = new Emitter<Set<LineFontChangingDecoration>>();
	public readonly onDidChangeFont = this._onDidChangeFont.event;

	private _fontAnnotatedString: IAnnotatedString<IFontTokenAnnotation> = new AnnotatedString<IFontTokenAnnotation>();

	constructor(
		private readonly textModel: ITextModel,
		private readonly tokenizationTextModelPart: TokenizationTextModelPart,
		private readonly configurationService: IConfigurationService
	) {
		super();
		this._register(this.tokenizationTextModelPart.onDidChangeFontTokens(fontChanges => {

			const linesChanged = new Set<number>();
			const fontTokenAnnotations: IAnnotationUpdate<IFontTokenAnnotation>[] = [];

			const affectedLineHeights = new Set<LineHeightMultiplierChangingDecoration>();
			const affectedLineFonts = new Set<LineFontChangingDecoration>();

			for (const annotation of fontChanges.changes.annotations) {

				const startPosition = this.textModel.getPositionAt(annotation.range.start);
				const endPosition = this.textModel.getPositionAt(annotation.range.endExclusive);

				if (startPosition.lineNumber !== endPosition.lineNumber) {

Review comment (suggestion):
The rename of this event to contain "Multiplier" seems a bit overkill, making things more complicated without too much value IMHO. Keeping the event name `onDidChangeLineHeight` and `LineHeightChangingDecoration` is IMHO good enough, the members can reflect that this is a multiplier.

Code after:
import { Disposable } from '../../../../base/common/lifecycle.js';
import { IModelDecoration, ITextModel } from '../../model.js';
import { TokenizationTextModelPart } from './tokenizationTextModelPart.js';
import { Range } from '../../core/range.js';
import { DecorationProvider, LineFontChangingDecoration, LineHeightChangingDecoration } from '../decorationProvider.js';
import { Emitter } from '../../../../base/common/event.js';
import { IFontTokenOption, IModelContentChangedEvent } from '../../textModelEvents.js';
import { classNameForFontTokenDecorations } from '../../languages/supports/tokenization.js';
import { Position } from '../../core/position.js';
import { AnnotatedString, AnnotationsUpdate, IAnnotatedString, IAnnotationUpdate } from './annotations.js';
import { OffsetRange } from '../../core/ranges/offsetRange.js';
import { offsetEditFromContentChanges } from '../textModelStringEdit.js';

export interface IFontTokenAnnotation {
	decorationId: string;
	fontToken: IFontTokenOption;
}

export class TokenizationFontDecorationProvider extends Disposable implements DecorationProvider {

	private static DECORATION_COUNT = 0;

	private readonly _onDidChangeLineHeight = new Emitter<Set<LineHeightChangingDecoration>>();
	public readonly onDidChangeLineHeight = this._onDidChangeLineHeight.event;

	private readonly _onDidChangeFont = new Emitter<Set<LineFontChangingDecoration>>();
	public readonly onDidChangeFont = this._onDidChangeFont.event;

	private _fontAnnotatedString: IAnnotatedString<IFontTokenAnnotation> = new AnnotatedString<IFontTokenAnnotation>();

	constructor(
		private readonly textModel: ITextModel,
		private readonly tokenizationTextModelPart: TokenizationTextModelPart
	) {
		super();
		this._register(this.tokenizationTextModelPart.onDidChangeFontTokens(fontChanges => {

			const linesChanged = new Set<number>();
			const fontTokenAnnotations: IAnnotationUpdate<IFontTokenAnnotation>[] = [];

			const affectedLineHeights = new Set<LineHeightChangingDecoration>();
			const affectedLineFonts = new Set<LineFontChangingDecoration>();

			for (const annotation of fontChanges.changes.annotations) {

				const startPosition = this.textModel.getPositionAt(annotation.range.start);
				const endPosition = this.textModel.getPositionAt(annotation.range.endExclusive);

				if (startPosition.lineNumber !== endPosition.lineNumber) {
					// The token should be always on a single line
					continue;