src/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.ts/normalizeRangeMapping
function normalizeRangeMapping(rangeMapping: RangeMapping, inputTextModel: ITextModel, outputTextModel: ITextModel): RangeMapping | undefined {
	const inputRangeEmpty = rangeMapping.inputRange.isEmpty();
	const outputRangeEmpty = rangeMapping.outputRange.isEmpty();

	if (inputRangeEmpty && outputRangeEmpty) {
		return undefined;
	}

	const originalStartsAtEndOfLine = isAtEndOfLine(rangeMapping.inputRange.startLineNumber, rangeMapping.inputRange.startColumn, inputTextModel);
	const modifiedStartsAtEndOfLine = isAtEndOfLine(rangeMapping.outputRange.startLineNumber, rangeMapping.outputRange.startColumn, outputTextModel);

	if (!inputRangeEmpty && !outputRangeEmpty && originalStartsAtEndOfLine && modifiedStartsAtEndOfLine) {
		// a b c [\n] x y z \n
		// d e f [\n a] \n
		// ->
		// a b c \n [] x y z \n
		// d e f \n [a] \n

		return new RangeMapping(
			rangeMapping.inputRange.setStartPosition(rangeMapping.inputRange.startLineNumber + 1, 1),

			rangeMapping.outputRange.setStartPosition(rangeMapping.outputRange.startLineNumber + 1, 1),
		);
	}

	if (
		modifiedStartsAtEndOfLine &&
		originalStartsAtEndOfLine &&
		((inputRangeEmpty && rangeEndsAtEndOfLine(rangeMapping.outputRange, outputTextModel)) ||
			(outputRangeEmpty && rangeEndsAtEndOfLine(rangeMapping.inputRange, inputTextModel)))
	) {
		// o: a b c [] \n x y z \n
		// m: d e f [\n a] \n
		// ->
		// o: a b c \n [] x y z \n
		// m: d e f \n [a \n]

		// or

		// a b c [\n x y z] \n
		// d e f [] \n a \n
		// ->
		// a b c \n [x y z \n]
		// d e f \n [] a \n

		return new RangeMapping(
			moveRange(rangeMapping.inputRange),
			moveRange(rangeMapping.outputRange)
		);
	}

	return rangeMapping;
}