Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultTextDoubleClickStrategyTest.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java4
2 files changed, 17 insertions, 3 deletions
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultTextDoubleClickStrategyTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultTextDoubleClickStrategyTest.java
index 94e9966b8..642638401 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultTextDoubleClickStrategyTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/DefaultTextDoubleClickStrategyTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2020 SAP SE and others.
+ * Copyright (c) 2020, 2021 SAP SE and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,6 +14,7 @@
package org.eclipse.jface.text.tests;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import org.junit.Test;
@@ -41,6 +42,19 @@ public class DefaultTextDoubleClickStrategyTest {
}
}
+ @Test
+ public void testClickAtLineEnd() throws Exception {
+ String content= "Hello world\nhow are you";
+ IDocument document= new Document(content);
+ TestSpecificDefaultTextDoubleClickStrategy doubleClickStrategy= new TestSpecificDefaultTextDoubleClickStrategy();
+ IRegion selection= doubleClickStrategy.findWord(document, 11);
+ assertNotNull("Should have selected a word", selection);
+ assertEquals("Unexpected selection", "world", document.get(selection.getOffset(), selection.getLength()));
+ selection= doubleClickStrategy.findWord(document, document.getLength());
+ assertNotNull("Should have selected a word", selection);
+ assertEquals("Unexpected selection", "you", document.get(selection.getOffset(), selection.getLength()));
+ }
+
private static final class TestSpecificDefaultTextDoubleClickStrategy extends DefaultTextDoubleClickStrategy {
@Override
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java
index 0ca3f4b17..58f7443d5 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextDoubleClickStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -267,7 +267,7 @@ public class DefaultTextDoubleClickStrategy implements ITextDoubleClickStrategy
return null;
}
- if (offset == line.getOffset() + line.getLength())
+ if (offset > line.getOffset() + line.getLength())
return null;
fDocIter.setDocument(document, line);

Back to the top