From d23cdff39e8c8311bf01f1152d5c175a8b0e3461 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Mon, 20 Mar 2017 11:35:00 +0300 Subject: [PATCH] add a separate range marker tree for fold regions, as they have now a different logic for update on document change this is required to avoid impact of folding regions on normal range markers (range marker tree expects all contained markers to be updated in the same way on document change) --- .../com/intellij/openapi/editor/impl/FoldRegionImpl.java | 2 +- .../com/intellij/openapi/editor/impl/FoldingModelImpl.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/FoldRegionImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/FoldRegionImpl.java index 8fe6ce3cc0f0..231852dca36e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/FoldRegionImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/FoldRegionImpl.java @@ -48,7 +48,7 @@ class FoldRegionImpl extends RangeMarkerImpl implements FoldRegion { @NotNull String placeholder, @Nullable FoldingGroup group, boolean shouldNeverExpand) { - super((DocumentEx)editor.getDocument(), startOffset, endOffset,true); + super((DocumentEx)editor.getDocument(), startOffset, endOffset,false); myGroup = group; myShouldNeverExpand = shouldNeverExpand; myIsExpanded = true; diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/FoldingModelImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/FoldingModelImpl.java index 803348f220a5..c0fac7260636 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/FoldingModelImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/FoldingModelImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,6 +61,7 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedInternalDocu private boolean myIsFoldingEnabled; private final EditorImpl myEditor; + private final RangeMarkerTree myRegionTree; private final FoldRegionsTree myFoldTree; private TextAttributes myFoldTextAttributes; private boolean myIsBatchFoldingProcessing; @@ -77,6 +78,7 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedInternalDocu myIsFoldingEnabled = true; myIsBatchFoldingProcessing = false; myDoNotCollapseCaret = false; + myRegionTree = new RangeMarkerTree<>(editor.getDocument()); myFoldTree = new FoldRegionsTree() { @Override protected boolean isFoldingEnabled() { @@ -314,6 +316,7 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedInternalDocu public void dispose() { doClearFoldRegions(); + myRegionTree.dispose(); } @Override @@ -580,6 +583,7 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedInternalDocu @Nullable FoldingGroup group, boolean neverExpands) { FoldRegionImpl region = new FoldRegionImpl(myEditor, startOffset, endOffset, placeholder, group, neverExpands); + myRegionTree.addInterval(region, startOffset, endOffset, false, false, 0); LOG.assertTrue(region.isValid()); return region; }