1. Reverted incorrect commit;

2. Checking if target offset belongs to document range;
This commit is contained in:
Denis Zhdanov
2011-01-31 10:33:19 +03:00
parent 396148f549
commit 0f781d5b8c
2 changed files with 3 additions and 4 deletions
@@ -59,7 +59,7 @@ public class GenericLineWrapPositionStrategy implements LineWrapPositionStrategy
maxPreferredOffsetToUse = maxPreferredOffsetToUse < startOffset ? startOffset : maxPreferredOffsetToUse;
// Try to find out wrap position before preferred offset.
for (int i = maxPreferredOffsetToUse; i > startOffset; i--) {
for (int i = Math.min(maxPreferredOffsetToUse, text.length() - 1); i > startOffset; i--) {
char c = text.charAt(i);
if (c == '\n') {
return i + 1;
@@ -99,7 +99,7 @@ public class GenericLineWrapPositionStrategy implements LineWrapPositionStrategy
// Try to find target offset that is beyond preferred offset.
// Note that we don't consider symbol weights here and just break on the first appropriate position.
if (!allowToBeyondMaxPreferredOffset) {
if (!allowToBeyondMaxPreferredOffset || maxPreferredOffset >= text.length() - 1) {
return maxPreferredOffset;
}
for (int i = maxPreferredOffsetToUse + 1; i < endOffset; i++) {
@@ -472,8 +472,7 @@ public class SoftWrapApplianceManager implements FoldingListener, DocumentListen
return i;
}
}
assert end > 0;
return end - 1;
return end;
}
private static int calculateWidthInColumns(char c, int widthInPixels, int spaceWithInPixels) {