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)
This commit is contained in:
Dmitry Batrak
2017-03-20 11:35:40 +03:00
parent 91d518a5e3
commit d23cdff39e
2 changed files with 6 additions and 2 deletions
@@ -48,7 +48,7 @@ class FoldRegionImpl extends RangeMarkerImpl implements FoldRegion {
@NotNull String placeholder, @NotNull String placeholder,
@Nullable FoldingGroup group, @Nullable FoldingGroup group,
boolean shouldNeverExpand) { boolean shouldNeverExpand) {
super((DocumentEx)editor.getDocument(), startOffset, endOffset,true); super((DocumentEx)editor.getDocument(), startOffset, endOffset,false);
myGroup = group; myGroup = group;
myShouldNeverExpand = shouldNeverExpand; myShouldNeverExpand = shouldNeverExpand;
myIsExpanded = true; myIsExpanded = true;
@@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 boolean myIsFoldingEnabled;
private final EditorImpl myEditor; private final EditorImpl myEditor;
private final RangeMarkerTree<FoldRegionImpl> myRegionTree;
private final FoldRegionsTree myFoldTree; private final FoldRegionsTree myFoldTree;
private TextAttributes myFoldTextAttributes; private TextAttributes myFoldTextAttributes;
private boolean myIsBatchFoldingProcessing; private boolean myIsBatchFoldingProcessing;
@@ -77,6 +78,7 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedInternalDocu
myIsFoldingEnabled = true; myIsFoldingEnabled = true;
myIsBatchFoldingProcessing = false; myIsBatchFoldingProcessing = false;
myDoNotCollapseCaret = false; myDoNotCollapseCaret = false;
myRegionTree = new RangeMarkerTree<>(editor.getDocument());
myFoldTree = new FoldRegionsTree() { myFoldTree = new FoldRegionsTree() {
@Override @Override
protected boolean isFoldingEnabled() { protected boolean isFoldingEnabled() {
@@ -314,6 +316,7 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedInternalDocu
public void dispose() { public void dispose() {
doClearFoldRegions(); doClearFoldRegions();
myRegionTree.dispose();
} }
@Override @Override
@@ -580,6 +583,7 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedInternalDocu
@Nullable FoldingGroup group, @Nullable FoldingGroup group,
boolean neverExpands) { boolean neverExpands) {
FoldRegionImpl region = new FoldRegionImpl(myEditor, startOffset, endOffset, placeholder, group, neverExpands); FoldRegionImpl region = new FoldRegionImpl(myEditor, startOffset, endOffset, placeholder, group, neverExpands);
myRegionTree.addInterval(region, startOffset, endOffset, false, false, 0);
LOG.assertTrue(region.isValid()); LOG.assertTrue(region.isValid());
return region; return region;
} }