EA-108926 - assert: TextRange.<init>

fix another case when invalidated folding region is not removed from group
This commit is contained in:
Dmitry Batrak
2019-02-14 14:21:37 +03:00
parent e7a396904e
commit 5fa744f0a1
2 changed files with 15 additions and 0 deletions
@@ -723,6 +723,7 @@ public class FoldingModelImpl extends InlayModel.SimpleAdapter
FoldRegionImpl otherRegion = getRegion(otherNode);
if (otherRegion.mySizeBeforeUpdate > region.mySizeBeforeUpdate) {
setNode(region, null);
removeRegionFromGroup(region);
removeIntervalInternal(0);
super.addIntervalsFrom(otherNode);
}
@@ -398,4 +398,18 @@ public class FoldingTest extends AbstractEditorTest {
FoldRegion region = addFoldRegion(0, 0, ".");
assertNull(region);
}
public void testRegionBecomingInvalidIsRemovedFromGroup() {
FoldingGroup group = FoldingGroup.newGroup("test");
myEditor.getFoldingModel().runBatchFoldingOperation(
() -> myModel.createFoldRegion(0, 10, "...", group, false)
);
addCollapsedFoldRegion(1, 10, "...");
WriteCommandAction.runWriteCommandAction(getProject(), () -> myEditor.getDocument().deleteString(0, 1));
List<FoldRegion> regions = myModel.getGroupedRegions(group);
assertEmpty(regions);
}
}