protected void setCaretPosition(EditorEx editor, TextRange range) {
      CaretModel caretModel = editor.getCaretModel();
      int offset = caretModel.getOffset();
      if (!range.contains(offset)) {
        caretModel.moveToOffset(range.getStartOffset());
      }
      editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
    }
protected void setCaretPosition(EditorEx editor, TextRange range)