IDEA-58070 Soft wrap: Improve soft wraps performance
authorDenis Zhdanov <Denis.Zhdanov@jetbrains.com>
Tue, 14 Sep 2010 07:26:55 +0000 (11:26 +0400)
committerDenis Zhdanov <Denis.Zhdanov@jetbrains.com>
Tue, 14 Sep 2010 07:26:55 +0000 (11:26 +0400)
Added additional check for situation with complete text removal

platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/CachingSoftWrapDataMapper.java

index 426e433beccbde914539f8ec1a4b4fe59f1becc3..9b5aefba32f4564390d2b88f51668dc503e32476 100644 (file)
@@ -371,8 +371,9 @@ public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAw
     if (!myBeforeChangeState.valid) {
       return;
     }
-    int endIndex = myCache.size() - 2; // -1 because of zero-based indexing; one more -1 in assumption that re-parsing always adds
-                                       // number of target cache entries plus one (because of line feed at the end).
+    int endIndex = Math.max(0, myCache.size() - 2); // -1 because of zero-based indexing; one more -1 in assumption that
+                                                    // re-parsing always adds number of target cache entries plus one
+                                                    // (because of line feed at the end).
     myAfterChangeState.updateByCacheIndices(myBeforeChangeState.startCacheEntryIndex, endIndex);
     myCache.subList(myAfterChangeState.endCacheEntryIndex + 1, myCache.size()).clear();
     myCache.addAll(myNotAffectedByUpdateTailCacheEntries);