void () { ThreadingAssertions.assertEventDispatchThread(); Editor editor = getEditor(); if (editor == null) return; boolean hasSelection = editor.getSelectionModel().hasSelection(); List<CaretState> prevSelection = hasSelection ? editor.getCaretModel().getCaretsAndSelections() : null; scrollToEnd(editor); if (prevSelection != null) { editor.getCaretModel().setCaretsAndSelections(prevSelection); } }