start = end = i;
// Make sure the word starts on a new line
if (resultLength > lineWidth) {
lineWidth = fPreferences.getMaxLineWidth();
resultLength = 0;
textEdit.addChild(new InsertEdit(start + startOffset, getLineDelimiter(region) + indent));
}
}
// Word is immediately after line delimiters, indent appropriately
if (onOwnLine) {
textEdit.addChild(new InsertEdit(i + startOffset, indent));
onOwnLine = false;
}
resultLength++;
}
}
// Clean up any dangling whitespace
int replaceLength = end - start;
indent = getIndentString(indentLevel);
if (replaceLength == 0) { // No trailing whitespace
textEdit.addChild(new InsertEdit(length + startOffset, (onOwnLine) ? indent : SPACE));
}
else {
String whitespace = text.substring(start);
String replacement = (onOwnLine) ? indent : SPACE;
if (!whitespace.equals(replacement)) {