diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerImpl.java index 9bb00e2e9ae3..fe0f72a9fb4a 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/RangeMarkerImpl.java @@ -37,6 +37,7 @@ public class RangeMarkerImpl extends UserDataHolderBase implements RangeMarkerEx private static final AtomicLong counter = new AtomicLong(); private final long myId; + private volatile int modCount; protected RangeMarkerImpl(@NotNull DocumentEx document, int start, int end) { if (start < 0) { @@ -102,6 +103,7 @@ public class RangeMarkerImpl extends UserDataHolderBase implements RangeMarkerEx } public final void documentChanged(DocumentEvent e) { + int modCount = this.modCount++; int oldStart = myStart; int oldEnd = myEnd; int docLength = myDocument.getTextLength(); @@ -119,7 +121,10 @@ public class RangeMarkerImpl extends UserDataHolderBase implements RangeMarkerEx changedUpdateImpl(e); if (isValid && (myStart > myEnd || myStart < 0 || myEnd > docLength)) { LOG.error("RangeMarker" + (isExpandToLeft ? "[" : "(") + oldStart + ", " + oldEnd + (isExpandToRight ? "]" : ")") + - " update failed. Event = " + e + ". Result[" + myStart + ", " + myEnd + "], doc length=" + docLength + "; "+getClass()); + " update failed. Event = " + e + ". Result[" + myStart + ", " + myEnd + "], " + + "old doc length=" + docLength + "; real doc length = "+myDocument.getTextLength()+ + "; old mod count="+modCount+"; mod count="+this.modCount+ + "; "+getClass()); isValid = false; } }