handle special case when InlineNodeReference was split completely

Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineNodeReference.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineNodeReference.java
index bdf1eca..f3ed08b 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineNodeReference.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/InlineNodeReference.java
@@ -326,9 +326,18 @@
 
 	@Override
 	public IInlineBox splitTail(final Graphics graphics, final int headWidth, final boolean force) {
+		final int firstChildOffset = findStartOffset(component);
+
 		final IInlineBox tailComponent = component.splitTail(graphics, headWidth, force);
 
-		final int splitPosition = findStartOffset(tailComponent);
+		final int firstTailOffset = findStartOffset(tailComponent);
+
+		final int splitPosition;
+		if (firstChildOffset == firstTailOffset) {
+			splitPosition = startPosition.getOffset();
+		} else {
+			splitPosition = firstTailOffset;
+		}
 		Assert.isTrue(splitPosition >= getStartOffset(), MessageFormat.format("Splitposition {0} is invalid.", splitPosition));
 
 		final InlineNodeReference tail = new InlineNodeReference();
@@ -365,7 +374,7 @@
 
 	@Override
 	public String toString() {
-		return "InlineNodeReference [parent=" + parent + ", top=" + top + ", left=" + left + ", width=" + width + ", height=" + height + ", baseline=" + baseline + ", startPosition=" + startPosition
+		return "InlineNodeReference [top=" + top + ", left=" + left + ", width=" + width + ", height=" + height + ", baseline=" + baseline + ", startPosition=" + startPosition
 				+ ", endPosition=" + endPosition + ", canContainText=" + canContainText + "]";
 	}
 }
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/Cursor.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/Cursor.java
index bc376a6..6792bb7 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/Cursor.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/cursor/Cursor.java
@@ -12,6 +12,7 @@
 
 import java.util.LinkedList;
 
+import org.eclipse.core.runtime.Assert;
 import org.eclipse.vex.core.internal.boxes.BaseBoxVisitorWithResult;
 import org.eclipse.vex.core.internal.boxes.DepthFirstBoxTraversal;
 import org.eclipse.vex.core.internal.boxes.IBox;
@@ -126,9 +127,7 @@
 
 	private void applyCaretForPosition(final Graphics graphics, final int offset) {
 		box = contentTopology.findBoxForPosition(offset);
-		if (box == null) {
-			return;
-		}
+		Assert.isNotNull(box, "No enclosing box found for the current caret position");
 		caret = getCaretForBox(graphics, box, offset);
 		if (preferX) {
 			preferredX = caret.getHotArea().getX();