src/vs/base/common/strings.ts/_getCharContainingOffset
function _getCharContainingOffset(str: string, offset: number): [number, number] {
	const graphemeBreakTree = GraphemeBreakTree.getInstance();
	const len = str.length;
	const initialOffset = offset;
	const initialCodePoint = getNextCodePoint(str, len, offset);
	const initialGraphemeBreakType = graphemeBreakTree.getGraphemeBreakType(initialCodePoint);
	offset += (initialCodePoint >= Constants.UNICODE_SUPPLEMENTARY_PLANE_BEGIN ? 2 : 1);

	// extend to the right
	let graphemeBreakType = initialGraphemeBreakType;
	while (offset < len) {
		const nextCodePoint = getNextCodePoint(str, len, offset);
		const nextGraphemeBreakType = graphemeBreakTree.getGraphemeBreakType(nextCodePoint);
		if (breakBetweenGraphemeBreakType(graphemeBreakType, nextGraphemeBreakType)) {
			break;
		}
		offset += (nextCodePoint >= Constants.UNICODE_SUPPLEMENTARY_PLANE_BEGIN ? 2 : 1);
		graphemeBreakType = nextGraphemeBreakType;
	}
	const endOffset = offset;

	// extend to the left
	offset = initialOffset;
	graphemeBreakType = initialGraphemeBreakType;
	while (offset > 0) {
		const prevCodePoint = getPrevCodePoint(str, offset);
		const prevGraphemeBreakType = graphemeBreakTree.getGraphemeBreakType(prevCodePoint);
		if (breakBetweenGraphemeBreakType(prevGraphemeBreakType, graphemeBreakType)) {
			break;
		}
		offset -= (prevCodePoint >= Constants.UNICODE_SUPPLEMENTARY_PLANE_BEGIN ? 2 : 1);
		graphemeBreakType = prevGraphemeBreakType;
	}

	return [offset, endOffset];
}