Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Singer2019-06-23 12:51:26 -0400
committerEric Williams2019-06-24 09:34:18 -0400
commitcafa676acdbc2341a1a1aa13e37281bd51315150 (patch)
tree93d3bae91eded5802b1fa4edeab03068c0707e01
parent44f5ac9f1f3cd90d7c723458bc3da22efe777a19 (diff)
downloadeclipse.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.java13
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 {

Back to the top