src/vs/editor/common/cursor/cursor.ts/CursorsController/onModelContentChanged
class CursorsController:	public onModelContentChanged(eventsCollector: ViewModelEventsCollector, event: InternalModelContentChangeEvent | ModelInjectedTextChangedEvent): void {
		if (event instanceof ModelInjectedTextChangedEvent) {
			// If injected texts change, the view positions of all cursors need to be updated.
			if (this._isHandling) {
				// The view positions will be updated when handling finishes
				return;
			}
			// setStates might remove markers, which could trigger a decoration change.
			// If there are injected text decorations for that line, `onModelContentChanged` is emitted again
			// and an endless recursion happens.
			// _isHandling prevents that.
			this._isHandling = true;
			try {
				this.setStates(eventsCollector, 'modelChange', CursorChangeReason.NotSet, this.getCursorStates());
			} finally {
				this._isHandling = false;
			}
		} else {
			const e = event.rawContentChangedEvent;
			this._knownModelVersionId = e.versionId;
			if (this._isHandling) {
				return;
			}

			const hadFlushEvent = e.containsEvent(RawContentChangedType.Flush);
			this._prevEditOperationType = EditOperationType.Other;

			if (hadFlushEvent) {
				// a model.setValue() was called
				this._cursors.dispose();
				this._cursors = new CursorCollection(this.context);
				this._validateAutoClosedActions();
				this._emitStateChangedIfNecessary(eventsCollector, 'model', CursorChangeReason.ContentFlush, null, false);
			} else {
				if (this._hasFocus && e.resultingSelection && e.resultingSelection.length > 0) {
					const cursorState = CursorState.fromModelSelections(e.resultingSelection);
					if (this.setStates(eventsCollector, 'modelChange', e.isUndoing ? CursorChangeReason.Undo : e.isRedoing ? CursorChangeReason.Redo : CursorChangeReason.RecoverFromMarkers, cursorState)) {
						this.revealPrimary(eventsCollector, 'modelChange', false, VerticalRevealType.Simple, true, editorCommon.ScrollType.Smooth);
					}
				} else {
					const selectionsFromMarkers = this._cursors.readSelectionFromMarkers();
					this.setStates(eventsCollector, 'modelChange', CursorChangeReason.RecoverFromMarkers, CursorState.fromModelSelections(selectionsFromMarkers));
				}
			}
		}
	}