public static void moveCaret(@NotNull Caret caret, int offset, boolean withSelection) {
    if (withSelection) {
      caret.setSelection(caret.getLeadSelectionOffset(), offset);
    }
    else {
      caret.removeSelection();
    }
    caret.moveToOffset(offset);
    EditorModificationUtilEx.scrollToCaret(caret.getEditor());
  }
public static void moveCaret(@NotNull Caret caret, int offset, boolean withSelection)