void () { // Implied by IDEA-79420 myFoldingSettings.setCollapseLambdas(true); @SuppressWarnings("ALL") @Language("JAVA") String text = """ class Test { void test() { new Runnable() { public void run() { int i = 1; } }.run(); } } """; configure(text); FoldingModelImpl foldingModel = (FoldingModelImpl)myFixture.getEditor().getFoldingModel(); final FoldRegion closureStartFold = foldingModel.getCollapsedRegionAtOffset(text.indexOf("Runnable")); assertNotNull(closureStartFold); assertFalse(closureStartFold.isExpanded()); assertNotNull(closureStartFold.getGroup()); List<FoldRegion> closureFolds = foldingModel.getGroupedRegions(closureStartFold.getGroup()); assertNotNull(closureFolds); assertEquals(2, closureFolds.size()); FoldRegion closureEndFold = closureFolds.get(1); assertFalse(closureEndFold.isExpanded()); myFixture.getEditor().getCaretModel().moveToOffset(closureEndFold.getStartOffset() + 1); assertTrue(closureStartFold.isExpanded()); assertTrue(closureEndFold.isExpanded()); changeFoldRegions(() -> collapse(closureStartFold)); assertTrue(closureStartFold.isExpanded()); assertTrue(closureEndFold.isExpanded()); }