private static int doReplace(Project project,
                               final Document document,
                               final int startOffset,
                               final int endOffset,
                               final String stringToReplace) {
    final String converted = StringUtil.convertLineSeparators(stringToReplace);
    CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> {
      //[ven] I doubt converting is a good solution to SCR 21224
      document.replaceString(startOffset, endOffset, converted);
    }), null, null);
    return startOffset + converted.length();
  }
private static int doReplace(Project project,
                               final Document document,
                               final int startOffset,
                               final int endOffset,
                               final String stringToReplace)