Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2021-08-24 18:05:22 -0400
committerThomas Wolf2021-09-21 10:47:59 -0400
commit98cec091524a841a4c224f450d590d4228ee0f8b (patch)
treec09d6809c5bb0c553398f862c68ea1735ca797cd
parent91f4d2bc8bca4c63984ce26e13cd26895e950d1e (diff)
downloadeclipse.platform.text-98cec091524a841a4c224f450d590d4228ee0f8b.tar.gz
eclipse.platform.text-98cec091524a841a4c224f450d590d4228ee0f8b.tar.xz
eclipse.platform.text-98cec091524a841a4c224f450d590d4228ee0f8b.zip
Bug 575608 - Double click beyond EOL should select last wordI20210921-1800
Change-Id: Icc7996eb5baee6cbb6c9e0340f5989353c8a5762 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch> Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.text/+/184385 Tested-by: Platform Bot <platform-bot@eclipse.org>
-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