void (@NotNull AnActionEvent e, boolean state) { Editor editor = myConsoleViewHandler.getEditor(); if (editor == null) return; if (state) { EditorUtil.scrollToTheEnd(editor); } else { int lastLine = Math.max(0, editor.getDocument().getLineCount() - 1); LogicalPosition currentPosition = editor.getCaretModel().getLogicalPosition(); LogicalPosition position = new LogicalPosition(Math.max(0, Math.min(currentPosition.line, lastLine - 1)), currentPosition.column); editor.getCaretModel().moveToLogicalPosition(position); } }