}
else {
// just collapse spaces, but adjust for any indenting that may result from preserving line delimiters
if (whitespaceStart == 0 && XMLFormattingConstraints.IGNOREANDTRIM.equals(whitespaceMode)) {
// if ignore, trim
DeleteEdit deleteTrailing = new DeleteEdit(startOffset, whitespaceRun.length());
textEdit.addChild(deleteTrailing);
}
else if(XMLFormattingConstraints.REPLACE.equals(whitespaceMode))
availableLineWidth = replaceSpaces(textEdit, startOffset, availableLineWidth, whitespaceRun);
else
availableLineWidth = collapseAndIndent(textEdit, startOffset, availableLineWidth, indentLevel, whitespaceRun, currentRegion);
}
fullTextOffset += characterRunLength;
}
else {
// handle trailing whitespace
int whitespaceOffset = currentRegion.getStartOffset() + whitespaceStart;
if (XMLFormattingConstraints.REPLACE.equals(whitespaceMode))
availableLineWidth = replaceSpaces(textEdit, whitespaceOffset, availableLineWidth, whitespaceRun);
else if (XMLFormattingConstraints.IGNOREANDTRIM.equals(whitespaceMode)) {
// always trim
DeleteEdit deleteTrailing = new DeleteEdit(whitespaceOffset, whitespaceRun.length());
textEdit.addChild(deleteTrailing);
}
else if(getFormattingPreferences().getClearAllBlankLines()) {
if (XMLFormattingConstraints.IGNORE.equals(whitespaceMode)) {
// if ignore, trim
DeleteEdit deleteTrailing = new DeleteEdit(whitespaceOffset, whitespaceRun.length());
textEdit.addChild(deleteTrailing);
}
else {
// if collapse, leave a space. but what if end up
// wanting to add indent? then need to delete space