boolean (final boolean next) { final Editor consoleEditor = myConsole.getCurrentEditor(); final Document document = consoleEditor.getDocument(); final CaretModel caretModel = consoleEditor.getCaretModel(); if (LookupManager.getActiveLookup(consoleEditor) != null) return false; if (next) { return document.getLineNumber(caretModel.getOffset()) == 0; } else { final int lineCount = document.getLineCount(); return (lineCount == 0 || document.getLineNumber(caretModel.getOffset()) == lineCount - 1) && (StringUtil.isEmptyOrSpaces(document.getText().substring(caretModel.getOffset())) || myHelper.getModel().prevOnLastLine()); } }