src/vs/workbench/contrib/audioCues/browser/audioCueLineFeatureContribution.ts/AudioCueLineFeatureContribution/registerAudioCuesForEditor
class AudioCueLineFeatureContribution:	private registerAudioCuesForEditor(
		editor: ICodeEditor,
		editorModel: ITextModel,
		store: DisposableStore
	): void {
		const curLineNumber = observableFromEvent(
			editor.onDidChangeCursorPosition,
			(args) => {
				if (
					args &&
					args.reason !== CursorChangeReason.Explicit &&
					args.reason !== CursorChangeReason.NotSet
				) {
					// Ignore cursor changes caused by navigation (e.g. which happens when execution is paused).
					return undefined;
				}
				return editor.getPosition()?.lineNumber;
			}
		);
		const debouncedLineNumber = debouncedObservable(curLineNumber, 300, store);

		const isTyping = wasEventTriggeredRecently(
			editorModel.onDidChangeContent.bind(editorModel),
			1000,
			store
		);

		const featureStates = this.features.map((feature) => {
			const lineFeatureState = feature.getObservableState(editor, editorModel);
			const isFeaturePresent = derivedObservable(
				`isPresentInLine:${feature.audioCue.name}`,
				(reader) => {
					if (!this.audioCueService.isEnabled(feature.audioCue).read(reader)) {
						return false;
					}
					const lineNumber = debouncedLineNumber.read(reader);
					return lineNumber === undefined
						? false
						: lineFeatureState.read(reader).isPresent(lineNumber);
				}
			);
			return derivedObservable(
				`typingDebouncedFeatureState:\n${feature.audioCue.name}`,
				(reader) =>
					feature.debounceWhileTyping && isTyping.read(reader)
						? (debouncedLineNumber.read(reader), isFeaturePresent.get())
						: isFeaturePresent.read(reader)
			);
		});

		const state = derivedObservable(
			'states',
			(reader) => ({
				lineNumber: debouncedLineNumber.read(reader),
				featureStates: new Map(
					this.features.map((feature, idx) => [
						feature,
						featureStates[idx].read(reader),
					])
				),
			})
		);

		store.add(
			autorunDelta('Play Audio Cue', state, ({ lastValue, newValue }) => {
				const newFeatures = this.features.filter(
					feature =>
						newValue?.featureStates.get(feature) &&
						(!lastValue?.featureStates?.get(feature) || newValue.lineNumber !== lastValue.lineNumber)
				);

				this.audioCueService.playAudioCues(newFeatures.map(f => f.audioCue));
			})
		);
	}