correct fold region length assertions, allow single character folding

This commit is contained in:
peter
2012-06-04 20:20:21 +02:00
parent a783fa5fd9
commit 0e35f229a4
3 changed files with 4 additions and 4 deletions
@@ -94,12 +94,12 @@ public class FoldingDescriptor {
@Nullable FoldingGroup group,
Set<Object> dependencies,
boolean neverExpands) {
assert range.getStartOffset() + 1 < range.getEndOffset() : range + ", text: " + node.getText() + ", language = " + node.getPsi().getLanguage();
assert range.getStartOffset() + 1 <= range.getEndOffset() : range + ", text: " + node.getText() + ", language = " + node.getPsi().getLanguage();
myElement = node;
ProperTextRange.assertProperRange(range);
myRange = range;
myGroup = group;
assert getRange().getLength() >= 2 : "range:" + getRange();
assert getRange().getLength() >= 1 : "range:" + getRange();
myDependencies = dependencies;
myNeverExpands = neverExpands;
}
@@ -91,7 +91,7 @@ public class FoldRegionImpl extends RangeMarkerImpl implements FoldRegion {
@Override
public boolean isValid() {
return super.isValid() && intervalStart() + 1 < intervalEnd();
return super.isValid() && intervalStart() + 1 <= intervalEnd();
}
public void setExpandedInternal(boolean toExpand) {
@@ -503,7 +503,7 @@ public class FoldingModelImpl implements FoldingModelEx, PrioritizedDocumentList
public FoldRegion createFoldRegion(int startOffset, int endOffset, @NotNull String placeholder, @Nullable FoldingGroup group,
boolean neverExpands)
{
if (startOffset + 1 >= endOffset) {
if (startOffset + 1 > endOffset) {
LOG.error("Invalid offsets: ("+startOffset+", "+endOffset+")");
}
FoldRegionImpl region = new FoldRegionImpl(myEditor, startOffset, endOffset, placeholder, group, neverExpands);