in src/java/org/jetbrains/plugins/clojure/repl/ClojureConsoleExecuteActionHandler.java [56:100]
public void runExecuteAction(final ClojureConsole console,
boolean executeImmediately) {
final ConsoleHistoryController consoleHistoryModel = console.getHistoryController();
if (executeImmediately) {
execute(console, consoleHistoryModel);
return;
}
// Process input and add to history
final Editor editor = console.getCurrentEditor();
final Document document = editor.getDocument();
final CaretModel caretModel = editor.getCaretModel();
final int offset = caretModel.getOffset();
final String text = document.getText();
if (!"".equals(text.substring(offset).trim())) {
final String before = text.substring(0, offset);
final String after = text.substring(offset);
final FileASTNode node = console.getFile().getNode();
final Project project = editor.getProject();
final int indent = myIndentHelper.getIndent(project, ClojureFileType.CLOJURE_FILE_TYPE, node);
final String spaces = IndentHelperImpl.fillIndent(project, ClojureFileType.CLOJURE_FILE_TYPE, indent);
final String newText = before + "\n" + spaces + after;
new WriteCommandAction(myProject) {
@Override
protected void run(Result result) throws Throwable {
console.setInputText(newText);
caretModel.moveToOffset(offset + indent + 1);
}
}.execute();
return;
}
final String candidate = text.trim();
// S-expression contains no syntax errors
if (ClojurePsiUtil.isValidClojureExpression(candidate, myProject) || "".equals(candidate)) {
execute(console, consoleHistoryModel);
} else {
console.setInputText(text + "\n");
}
}