[229135] Format Source doesn't work XML files containing certain text
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/DefaultXMLPartitionFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/DefaultXMLPartitionFormatter.java
index 337934a..8e1eb19 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/DefaultXMLPartitionFormatter.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/formatter/DefaultXMLPartitionFormatter.java
@@ -285,7 +285,7 @@
*/
private void formatContent(TextEdit textEdit, Position formatRange, XMLFormattingConstraints parentConstraints, DOMRegion currentDOMRegion, IStructuredDocumentRegion previousRegion) {
IStructuredDocumentRegion currentRegion = currentDOMRegion.documentRegion;
- String fullText = currentRegion.getFullText();
+ String fullText = currentDOMRegion.domNode.getSource();
// check if in preserve space mode, if so, don't touch anything but
// make sure to update available line width
@@ -328,6 +328,9 @@
}
}
formatTextInContent(textEdit, parentConstraints, currentRegion, fullText, whitespaceMode);
+ // A text node can contain multiple structured document regions - sync the documentRegion
+ // with the last region of the node since the text from all regions was formatted
+ currentDOMRegion.documentRegion = currentDOMRegion.domNode.getLastStructuredDocumentRegion();
}
private void formatEmptyStartTagWithNoAttr(TextEdit textEdit, XMLFormattingConstraints constraints, IStructuredDocumentRegion currentDocumentRegion, IStructuredDocumentRegion previousDocumentRegion, int availableLineWidth, String indentStrategy, String whitespaceStrategy, ITextRegion currentTextRegion) {
@@ -433,7 +436,7 @@
formatEndTag(edit, formatRange, parentConstraints, domRegion, previousRegion);
}
}
- else if (regionType == DOMRegionContext.XML_CONTENT) {
+ else if (regionType == DOMRegionContext.XML_CONTENT || domRegion.domNode.getNodeType() == Node.TEXT_NODE) {
formatContent(edit, formatRange, parentConstraints, domRegion, previousRegion);
}
else if (regionType == DOMRegionContext.XML_COMMENT_TEXT) {