diff options
author | Thomas Singer | 2019-06-23 16:51:26 +0000 |
---|---|---|
committer | Eric Williams | 2019-06-24 13:34:18 +0000 |
commit | cafa676acdbc2341a1a1aa13e37281bd51315150 (patch) | |
tree | 93d3bae91eded5802b1fa4edeab03068c0707e01 | |
parent | 44f5ac9f1f3cd90d7c723458bc3da22efe777a19 (diff) | |
download | eclipse.platform.swt-cafa676acdbc2341a1a1aa13e37281bd51315150.tar.gz eclipse.platform.swt-cafa676acdbc2341a1a1aa13e37281bd51315150.tar.xz eclipse.platform.swt-cafa676acdbc2341a1a1aa13e37281bd51315150.zip |
Bug 545846 - StyledText: wrong word selected on double-click
Change-Id: Ie1ec7c848b937a9f577382f56aa00171f0c9f2a4
Signed-off-by: Thomas Singer <ts-swt@syntevo.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java index 676bc7ff1d..5b15ec4ae6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java @@ -6184,8 +6184,17 @@ void handleMouseDown(Event event) { if (wordSelect) { int min = blockSelection ? lineOffset : 0; int max = blockSelection ? lineOffset + content.getLine(lineIndex).length() : content.getCharCount(); - int start = Math.max(min, getWordPrevious(offset, SWT.MOVEMENT_WORD_START)); - int end = Math.min(max, getWordNext(start, SWT.MOVEMENT_WORD_END)); + int start; + int end; + final Point offsetPoint = getPointAtOffset(offset); + if (event.x > offsetPoint.x) { + end = Math.min(max, getWordNext(offset, SWT.MOVEMENT_WORD_END)); + start = Math.max(min, getWordPrevious(end, SWT.MOVEMENT_WORD_START)); + } + else { + start = Math.max(min, getWordPrevious(offset, SWT.MOVEMENT_WORD_START)); + end = Math.min(max, getWordNext(start, SWT.MOVEMENT_WORD_END)); + } setSelection(start, end - start, false, true); sendSelectionEvent(); } else { |