src/vs/workbench/common/editor/editorOptions.ts/massageEditorViewState
function massageEditorViewState(options: ITextEditorOptions): object | undefined {

	// Without a selection or view state, just return immediately
	if (!options.selection || !options.viewState) {
		return options.viewState;
	}

	// Diff editor: since we have an explicit selection, clear the
	// cursor state from the modified side where the selection
	// applies. This avoids a redundant selection change event.
	const candidateDiffViewState = options.viewState as IDiffEditorViewState;
	if (candidateDiffViewState.modified) {
		candidateDiffViewState.modified.cursorState = [];

		return candidateDiffViewState;
	}

	// Code editor: since we have an explicit selection, clear the
	// cursor state. This avoids a redundant selection change event.
	const candidateEditorViewState = options.viewState as ICodeEditorViewState;
	if (candidateEditorViewState.cursorState) {
		candidateEditorViewState.cursorState = [];
	}

	return candidateEditorViewState;
}