public static int getPreviousCodePointOffset(@NotNull Document document, int offset) {
    return offset - (isSurrogatePair(document, offset - 2) ? 2 : 1);
  }
public static int getPreviousCodePointOffset(@NotNull Document document, int offset)