void (@NotNull VisibleAreaEvent e) { ReadAction.run(() -> { Rectangle oldRectangle = e.getOldRectangle(); Rectangle newRectangle = e.getNewRectangle(); if (!myScrollingToCaret && oldRectangle != null && oldRectangle.height != newRectangle.height && oldRectangle.y == newRectangle.y && newRectangle.height > 0) { int caretY = myView.visualLineToY(myCaretModel.getVisualPosition().line); if (caretY < oldRectangle.getMaxY() && caretY > newRectangle.getMaxY()) { myScrollingToCaret = true; ApplicationManager.getApplication().invokeLater(() -> { myScrollingToCaret = false; if (!isReleased) EditorUtil.runWithAnimationDisabled(this, () -> myScrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE)); }, ModalityState.any()); } } }); }