void () { Ref<FoldRegion> regionRef = new Ref<>(); runFoldingOperation(() -> { FoldRegion region = myModel.createFoldRegion(0, 1, "...", null, true); assertNotNull(region); assertTrue(region.isValid()); assertFalse(region.isExpanded()); regionRef.set(region); }); List<FoldRegion> notifications = new ArrayList<>(); myModel.addListener(new FoldingListener() { @Override public void onFoldRegionStateChange(@NotNull FoldRegion region) { notifications.add(region); } }, getTestRootDisposable()); runFoldingOperation(() -> myModel.removeFoldRegion(regionRef.get())); assertSize(1, notifications); assertEquals(regionRef.get(), notifications.get(0)); }