private void doInsertUserInput(@NotNull Editor editor, int offset, @NotNull String text) {
    ThreadingAssertions.assertEventDispatchThread();
    Document document = editor.getDocument();

    int oldDocLength = document.getTextLength();
    document.insertString(offset, text);
    int newStartOffset = Math.max(0,document.getTextLength() - oldDocLength + offset - text.length()); // take care of trim document
    int newEndOffset = document.getTextLength() - oldDocLength + offset; // take care of trim document

    if (ConsoleTokenUtil.findTokenMarker(getEditor(), getProject(), newEndOffset) == null) {
      ConsoleTokenUtil.createTokenRangeHighlighter(getEditor(), getProject(), ConsoleViewContentType.USER_INPUT, newStartOffset, newEndOffset, !text.equals("\n"));
    }

    moveScrollRemoveSelection(editor, newEndOffset);
    sendUserInput(text);
  }
private void doInsertUserInput(@NotNull Editor editor, int offset, @NotNull String text)