src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer.ts/PieceTreeTextBuffer/getValueLengthInRange
class PieceTreeTextBuffer:	public getValueLengthInRange(range: Range, eol: EndOfLinePreference = EndOfLinePreference.TextDefined): number {
		if (range.isEmpty()) {
			return 0;
		}

		if (range.startLineNumber === range.endLineNumber) {
			return (range.endColumn - range.startColumn);
		}

		const startOffset = this.getOffsetAt(range.startLineNumber, range.startColumn);
		const endOffset = this.getOffsetAt(range.endLineNumber, range.endColumn);

		// offsets use the text EOL, so we need to compensate for length differences
		// if the requested EOL doesn't match the text EOL
		let eolOffsetCompensation = 0;
		const desiredEOL = this._getEndOfLine(eol);
		const actualEOL = this.getEOL();
		if (desiredEOL.length !== actualEOL.length) {
			const delta = desiredEOL.length - actualEOL.length;
			const eolCount = range.endLineNumber - range.startLineNumber;
			eolOffsetCompensation = delta * eolCount;
		}

		return endOffset - startOffset + eolOffsetCompensation;
	}