mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-163134 Editor sometimes hangs when moving parameters
This commit is contained in:
@@ -373,10 +373,12 @@ public class RangeMarkerTree<T extends RangeMarkerEx> extends IntervalTreeImpl<T
|
||||
List<IntervalNode<T>> affected = new ArrayList<IntervalNode<T>>();
|
||||
collectNodesToRetarget(getRoot(), start, end, affected);
|
||||
if (affected.isEmpty()) return;
|
||||
|
||||
int shift = newBase - start;
|
||||
// remove all first because findOrInsert can remove gced nodes which could interfere with not-yet-removed nodes
|
||||
for (IntervalNode<T> node : affected) {
|
||||
removeNode(node);
|
||||
}
|
||||
int shift = newBase - start;
|
||||
for (IntervalNode<T> node : affected) {
|
||||
node.setLeft(null);
|
||||
node.setRight(null);
|
||||
node.setParent(null);
|
||||
|
||||
@@ -1203,4 +1203,19 @@ public class RangeMarkerTest extends LightPlatformTestCase {
|
||||
assertValidMarker(marker, 0, 9);
|
||||
}
|
||||
|
||||
public void testMoveTextCrashes() {
|
||||
DocumentEx doc = new DocumentImpl(StringUtil.repeat("blah", 1000));
|
||||
Random random = new Random();
|
||||
for(int i = 0; i < 10000; i++) {
|
||||
int limit = doc.getTextLength() + 1;
|
||||
int offset = random.nextInt(limit);
|
||||
doc.createRangeMarker(offset, offset);
|
||||
int startOffset = random.nextInt(limit);
|
||||
int endOffset = random.nextInt(limit);
|
||||
int targetOffset = random.nextInt(limit);
|
||||
if (endOffset > startOffset && (targetOffset < startOffset || targetOffset > endOffset)) {
|
||||
doc.moveText(startOffset, endOffset, targetOffset);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user