void (@Nullable Editor editor, boolean stopAnimation, @NotNull Runnable operation) { if (editor == null || editor instanceof ImaginaryEditor) { operation.run(); return; } EditorScrollingPositionKeeper keeper = new EditorScrollingPositionKeeper(editor); keeper.savePosition(); try { operation.run(); keeper.restorePosition(stopAnimation); } finally { Disposer.dispose(keeper); } }