{
// If no selection, unfold the closest fold on the current row
Position pos = range.getStart();
AceFold startCandidate = null;
AceFold endCandidate = null;
for (AceFold f : JsUtil.asIterable(docDisplay_.getFolds()))
{
if (startCandidate == null
&& f.getStart().getRow() == pos.getRow()
&& f.getStart().getColumn() >= pos.getColumn())
{
startCandidate = f;
}
if (f.getEnd().getRow() == pos.getRow()
&& f.getEnd().getColumn() <= pos.getColumn())
{
endCandidate = f;
}
}
if (startCandidate == null ^ endCandidate == null)
{
docDisplay_.unfold(startCandidate != null ? startCandidate
: endCandidate);
}
else if (startCandidate != null)
{
// Both are candidates; see which is closer
int startDelta = startCandidate.getStart().getColumn() - pos.getColumn();
int endDelta = pos.getColumn() - endCandidate.getEnd().getColumn();
docDisplay_.unfold(startDelta <= endDelta? startCandidate
: endCandidate);
}
}
else