public static int alignToCodePointBoundary(@NotNull Document document, int offset) {
    return isInsideSurrogatePair(document, offset) ? offset - 1 : offset;
  }
public static int alignToCodePointBoundary(@NotNull Document document, int offset)