[224885] Content Assist works strange in some case
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java
index 4eaebd7..2e3e0cb 100644
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java
+++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java
@@ -1949,10 +1949,10 @@
 			if (node.getStructuredDocument().getLength() == 0) {
 				return null;
 			}
-			ITextRegion result = node.getStructuredDocument().getRegionAtCharacterOffset(offset).getRegionAtCharacterOffset(offset);
+			ITextRegion result = getContentRegion(offset, node);
 			while (result == null) {
 				offset--;
-				result = node.getStructuredDocument().getRegionAtCharacterOffset(offset).getRegionAtCharacterOffset(offset);
+				result = getContentRegion(offset, node);
 			}
 			return result;
 		}
@@ -1976,38 +1976,52 @@
 			region = getCompletionRegion(offset, flatNode);
 		}
 		else {
-			// the docPosition is neither within the start nor the end, so it
-			// must be content
-			flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(offset);
-			// (pa) ITextRegion refactor
-			// if (flatNode.contains(documentPosition)) {
-			if ((flatNode.getStartOffset() <= documentPosition) && (flatNode.getEndOffset() >= documentPosition)) {
-				// we're interesting in completing/extending the previous
-				// IStructuredDocumentRegion if the current
-				// IStructuredDocumentRegion isn't plain content or if it's
-				// preceded by an orphan '<'
-				if ((offset == flatNode.getStartOffset()) && (flatNode.getPrevious() != null) && (((flatNode.getRegionAtCharacterOffset(documentPosition) != null) && (flatNode.getRegionAtCharacterOffset(documentPosition).getType() != DOMRegionContext.XML_CONTENT)) || (flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_TAG_OPEN) || (flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN))) {
-					// Is the region also the start of the node? If so, the
-					// previous IStructuredDocumentRegion is
-					// where to look for a useful region.
-					region = flatNode.getPrevious().getLastRegion();
-				}
-				else if (flatNode.getEndOffset() == documentPosition) {
-					region = flatNode.getLastRegion();
-				}
-				else {
-					region = flatNode.getFirstRegion();
-				}
-			}
-			else {
-				// catch end of document positions where the docPosition isn't
-				// in a IStructuredDocumentRegion
-				region = flatNode.getLastRegion();
-			}
+			region = getContentRegion(offset, node);
 		}
 
 		return region;
 	}
+	
+	/**
+	 * Find the region within the content
+	 * @param offset offset within the document
+	 * @param node 
+	 * @param flatNode
+	 * @return
+	 */
+	private ITextRegion getContentRegion(int offset, IDOMNode node) {
+		ITextRegion region = null;
+		
+		// the docPosition is neither within the start nor the end, so it
+		// must be content
+		IStructuredDocumentRegion flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(offset);
+		// (pa) ITextRegion refactor
+		// if (flatNode.contains(documentPosition)) {
+		if ((flatNode.getStartOffset() <= offset) && (flatNode.getEndOffset() >= offset)) {
+			// we're interesting in completing/extending the previous
+			// IStructuredDocumentRegion if the current
+			// IStructuredDocumentRegion isn't plain content or if it's
+			// preceded by an orphan '<'
+			if ((offset == flatNode.getStartOffset()) && (flatNode.getPrevious() != null) && (((flatNode.getRegionAtCharacterOffset(offset) != null) && (flatNode.getRegionAtCharacterOffset(offset).getType() != DOMRegionContext.XML_CONTENT)) || (flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_TAG_OPEN) || (flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN))) {
+				// Is the region also the start of the node? If so, the
+				// previous IStructuredDocumentRegion is
+				// where to look for a useful region.
+				region = flatNode.getPrevious().getLastRegion();
+			}
+			else if (flatNode.getEndOffset() == offset) {
+				region = flatNode.getLastRegion();
+			}
+			else {
+				region = flatNode.getFirstRegion();
+			}
+		}
+		else {
+			// catch end of document positions where the docPosition isn't
+			// in a IStructuredDocumentRegion
+			region = flatNode.getLastRegion();
+		}
+		return region;
+	}
 
 	/**
 	 * Provided by default. Subclasses may override with their own