IDEA-58625 Exception on paste

Incremental update of soft wraps cache is corrected
This commit is contained in:
Denis Zhdanov
2010-09-13 17:21:59 +04:00
parent 75b5d0ccd6
commit 55afdb4bfe
2 changed files with 23 additions and 6 deletions
@@ -392,10 +392,21 @@ public class CachingSoftWrapDataMapper implements SoftWrapDataMapper, SoftWrapAw
//System.out.println("text length: " + text.length() + ", soft wraps: " + myStorage.getSoftWraps());
//for (int i = 0; i < myCache.size(); i++) {
// CacheEntry entry = myCache.get(i);
// System.out.printf("line %d. %d-%d: '%s'%n", i, entry.startOffset, entry.endOffset,
// text.subSequence(entry.startOffset,Math.min(entry.endOffset, text.length())));
// // TODO den unwrap
// try {
// System.out.printf("line %d. %d-%d: '%s'%n", i, entry.startOffset, entry.endOffset,
// text.subSequence(entry.startOffset,Math.min(entry.endOffset, text.length())));
// }
// catch (Throwable e) {
// e.printStackTrace();
// }
//}
//
//if (!myCache.isEmpty() && myCache.get(myCache.size() - 1).endOffset < text.length() - 1) {
// System.out.printf("Incomplete re-parsing detected! Document length is %d but last processed offset is %s%n", text.length(),
// myCache.get(myCache.size() - 1).endOffset);
//}
//for (CacheEntry cacheEntry : myCache) {
// if (cacheEntry.startOffset > 0) {
// if (text.charAt(cacheEntry.startOffset - 1) != '\n' && myStorage.getSoftWrap(cacheEntry.startOffset) == null) {
@@ -128,7 +128,9 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
}
private void recalculateSoftWraps(DirtyRegion region) {
notifyListenersOnRangeRecalculation(region, true);
if (region.notifyAboutRecalculationStart) {
notifyListenersOnRangeRecalculation(region, true);
}
myStorage.removeInRange(region.startRange.getStartOffset(), region.startRange.getEndOffset());
try {
region.beforeRecalculation();
@@ -535,7 +537,9 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
@Override
public void beforeDocumentChange(DocumentEvent event) {
myDirtyRegions.add(new DirtyRegion(event));
DirtyRegion region = new DirtyRegion(event);
myDirtyRegions.add(region);
notifyListenersOnRangeRecalculation(region, true);
}
@Override
@@ -548,11 +552,13 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
public TextRange startRange;
public TextRange endRange;
public boolean notifyAboutRecalculationStart;
private boolean myRecalculateEnd;
DirtyRegion(int startOffset, int endOffset) {
startRange = new TextRange(startOffset, endOffset);
endRange = new TextRange(startOffset, endOffset);
notifyAboutRecalculationStart = true;
}
DirtyRegion(DocumentEvent event) {
@@ -596,7 +602,7 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
case ' ': indentInColumns += 1; indentInPixels += spaceWidth; break;
case '\t':
int x = EditorUtil.nextTabStop(indentInPixels, editor);
indentInColumns = calculateWidthInColumns(x - indentInPixels, spaceWidth);
indentInColumns += calculateWidthInColumns(x - indentInPixels, spaceWidth);
indentInPixels = x;
break;
default: myNonWhiteSpaceSymbolOffset = i; return;