public static boolean isAtLineEnd(@NotNull Editor editor, int offset) {
    return ReadAction.compute(() -> {
      Document document = editor.getDocument();
      if (offset < 0 || offset > document.getTextLength()) {
        return false;
      }
      int line = document.getLineNumber(offset);
      return offset == document.getLineEndOffset(line);
    });
  }
public static boolean isAtLineEnd(@NotNull Editor editor, int offset)