diff --git a/platform/core-impl/src/com/intellij/openapi/editor/impl/CharArray.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/CharArray.java
index a3f9d7d5b652..08c65c2ac35f 100644
--- a/platform/core-impl/src/com/intellij/openapi/editor/impl/CharArray.java
+++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/CharArray.java
@@ -44,7 +44,7 @@ abstract class CharArray implements CharSequenceBackedByArray {
private static final boolean DISABLE_DEFERRED_PROCESSING = Boolean.getBoolean("idea.document.deny.deferred.changes");
@SuppressWarnings("UseOfArchaicSystemPropertyAccessors")
- private static final boolean DEBUG_DEFERRED_PROCESSING = LOG.isDebugEnabled() || Boolean.getBoolean("idea.document.debug.bulk.processing");
+ private static final boolean DEBUG_DEFERRED_PROCESSING = LOG.isDebugEnabled() || Boolean.getBoolean("idea.document.debug.bulk.processing") || DocumentImpl.CHECK_DOCUMENT_CONSISTENCY;
/**
* We can't exclude possibility of situation when 'defer changes' state is {@link #setDeferredChangeMode(boolean) entered}
* but not exited, hence, we want to perform automatic flushing if necessary in order to avoid memory leaks. This constant holds
diff --git a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java
index 18c0a2347654..f777f1b92b76 100644
--- a/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java
+++ b/platform/core-impl/src/com/intellij/openapi/editor/impl/DocumentImpl.java
@@ -50,6 +50,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
public class DocumentImpl extends UserDataHolderBase implements DocumentEx {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.editor.impl.DocumentImpl");
+ public static boolean CHECK_DOCUMENT_CONSISTENCY = true;
private final CopyOnWriteArrayList myDocumentListeners = ContainerUtil.createEmptyCOWList();
private final RangeMarkerTree myRangeMarkers = new RangeMarkerTree(this);
diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java
index 01eca8e8d941..f4e051cf3f87 100644
--- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java
@@ -45,6 +45,7 @@ import com.intellij.openapi.command.undo.UndoManager;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.EditorFactory;
+import com.intellij.openapi.editor.impl.DocumentImpl;
import com.intellij.openapi.editor.impl.EditorFactoryImpl;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl;
@@ -335,6 +336,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
storeSettings();
myThreadTracker = new ThreadTracker();
+ DocumentImpl.CHECK_DOCUMENT_CONSISTENCY = !isPerformanceTest();
}
public static void doSetup(final LightProjectDescriptor descriptor,
diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java
index 6eaef6b87234..84a3123ea6cf 100644
--- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java
+++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestCase.java
@@ -36,6 +36,7 @@ import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.editor.event.DocumentListener;
+import com.intellij.openapi.editor.impl.DocumentImpl;
import com.intellij.openapi.module.EmptyModuleType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
@@ -189,6 +190,7 @@ public abstract class PlatformTestCase extends UsefulTestCase implements DataPro
}
DocumentCommitThread.getInstance().clearQueue();
+ DocumentImpl.CHECK_DOCUMENT_CONSISTENCY = !isPerformanceTest();
}
public Project getProject() {