void (final Entry command, final boolean storeUserText, final boolean regularMode) { if (regularMode && myMultiline && StringUtil.isEmptyOrSpaces(command.text())) return; final Editor editor = myConsole.getCurrentEditor(); final Document document = editor.getDocument(); WriteCommandAction.writeCommandAction(myConsole.getProject()).run(() -> { if (storeUserText) { String text = document.getText(); if (Comparing.equal(command.text(), text) && myHelper.getContent() != null) return; myHelper.setContent(text); myHelper.getModel().setContent(text); } CharSequence text = Objects.requireNonNullElse(command.text(), ""); int offset; if (regularMode) { if (myMultiline) { offset = insertTextMultiline(text, editor, document); } else { document.setText(text); offset = command.offset() == -1 ? document.getTextLength() : command.offset(); } } else { offset = 0; UndoUtil.disableUndoIn(document, () -> document.setText(text)); } editor.getCaretModel().moveToOffset(offset); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); }); }