void (boolean isNext) { EditorEx consoleEditor = getConsoleView().getConsoleEditor(); ApplicationManager.getApplication().runReadAction(() -> { int offset = consoleEditor.getCaretModel().getOffset(); int caretLine = consoleEditor.getDocument().getLineNumber(offset); int linesCount = consoleEditor.getDocument().getLineCount(); if (linesCount > 1) { if (isNext) { assertEquals(0, caretLine); } else { assertEquals(linesCount - 1, caretLine); } } else { assertEquals(0, caretLine); } }); }