223513 - StyledText crashes on double-click of whitespace
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java
index f3148b5..7698c40 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/TextLayout.java
@@ -732,11 +732,11 @@
 			return untranslateOffset(textStorage.nextWordFromIndex(offset, forward));
 		}
 		case SWT.MOVEMENT_WORD_END: {
-			NSRange range = textStorage.doubleClickAtIndex(offset);
+			NSRange range = textStorage.doubleClickAtIndex(length == offset ? length - 1 : offset);
 			return untranslateOffset(range.location + range.length);
 		}
 		case SWT.MOVEMENT_WORD_START: {
-			NSRange range = textStorage.doubleClickAtIndex(offset);
+			NSRange range = textStorage.doubleClickAtIndex(length == offset ? length - 1 : offset);
 			return untranslateOffset(range.location);
 		}
 		default: