void (@NotNull Editor editor, @NotNull Runnable taskWithScrolling) { ScrollingModel scrollingModel = editor.getScrollingModel(); if (!(scrollingModel instanceof ScrollingModelImpl)) { taskWithScrolling.run(); } else { boolean animationWasEnabled = ((ScrollingModelImpl)scrollingModel).isAnimationEnabled(); scrollingModel.disableAnimation(); try { taskWithScrolling.run(); } finally { if (animationWasEnabled) scrollingModel.enableAnimation(); } } }