CharSequence (@NotNull Editor editor, @NotNull Project project) { StringBuilder textToSend = new StringBuilder(); // compute text input from the console contents: // all range markers beginning from the caret offset backwards, marked as user input and not marked as already sent for (RangeMarker marker = findTokenMarker(editor, project, editor.getCaretModel().getOffset() - 1); marker != null; marker = ((RangeMarkerImpl)marker).findRangeMarkerBefore()) { ConsoleViewContentType tokenType = getTokenType(marker); if (tokenType != null) { if (tokenType != ConsoleViewContentType.USER_INPUT || marker.getUserData(USER_INPUT_SENT) == Boolean.TRUE) { break; } marker.putUserData(USER_INPUT_SENT, true); textToSend.insert(0, marker.getDocument().getText(marker.getTextRange())); } } return textToSend; }