mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
prevent fold regions from 'disappearing' if no one references them
supposedly fixes EA-107809 - AIOOBE: TIntArrayList.insert
This commit is contained in:
@@ -7,11 +7,12 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.FoldRegion;
|
||||
import com.intellij.openapi.editor.FoldingGroup;
|
||||
import com.intellij.openapi.editor.event.DocumentEvent;
|
||||
import com.intellij.openapi.util.Getter;
|
||||
import com.intellij.util.DocumentUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
class FoldRegionImpl extends RangeMarkerImpl implements FoldRegion {
|
||||
class FoldRegionImpl extends RangeMarkerImpl implements FoldRegion, Getter<FoldRegionImpl> {
|
||||
private boolean myIsExpanded;
|
||||
private final EditorImpl myEditor;
|
||||
private final String myPlaceholderText;
|
||||
@@ -65,6 +66,11 @@ class FoldRegionImpl extends RangeMarkerImpl implements FoldRegion {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FoldRegionImpl get() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private static void doSetExpanded(boolean expanded, FoldingModelImpl foldingModel, FoldRegion region, boolean notify) {
|
||||
if (expanded) {
|
||||
foldingModel.expandFoldRegion(region, notify);
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.intellij.openapi.editor.ex.FoldingModelEx;
|
||||
import com.intellij.openapi.editor.ex.PrioritizedInternalDocumentListener;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Getter;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.ModificationTracker;
|
||||
import com.intellij.util.DocumentUtil;
|
||||
@@ -59,7 +60,24 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedInternalDocu
|
||||
myIsFoldingEnabled = true;
|
||||
myIsBatchFoldingProcessing = false;
|
||||
myDoNotCollapseCaret = false;
|
||||
myRegionTree = new RangeMarkerTree<>(editor.getDocument());
|
||||
myRegionTree = new RangeMarkerTree<FoldRegionImpl>(editor.getDocument()) {
|
||||
@NotNull
|
||||
@Override
|
||||
protected RMNode<FoldRegionImpl> createNewNode(@NotNull FoldRegionImpl key,
|
||||
int start,
|
||||
int end,
|
||||
boolean greedyToLeft,
|
||||
boolean greedyToRight,
|
||||
boolean stickingToRight,
|
||||
int layer) {
|
||||
return new RMNode<FoldRegionImpl>(this, key, start, end, greedyToLeft, greedyToRight, stickingToRight) {
|
||||
@Override
|
||||
protected Getter<FoldRegionImpl> createGetter(@NotNull FoldRegionImpl region) {
|
||||
return region;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
myFoldTree = new FoldRegionsTree(myRegionTree) {
|
||||
@Override
|
||||
protected boolean isFoldingEnabled() {
|
||||
|
||||
Reference in New Issue
Block a user