private int getCurrentCaretOffset(int caretOffset) {
    Editor editor = getEditor();
    return editor != null ? editor.getCaretModel().getOffset() : caretOffset;
  }
private int getCurrentCaretOffset(int caretOffset)