src/vs/base/common/strings.ts/getLeftDeleteOffset
export function getLeftDeleteOffset(offset: number, str: string): number {
	if (offset === 0) {
		return 0;
	}

	// Try to delete emoji part.
	const emojiOffset = getOffsetBeforeLastEmojiComponent(offset, str);
	if (emojiOffset !== undefined) {
		return emojiOffset;
	}

	// Otherwise, just skip a single code point.
	const iterator = new CodePointIterator(str, offset);
	iterator.prevCodePoint();
	return iterator.offset;
}