Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2019-02-25 19:07:45 +0000
committerEric Williams2019-02-26 16:00:19 +0000
commit01afcdc0fb8782ec7a80728fedb1495e0212ed01 (patch)
treee486073f62a1736cfac3e5f4966f3b58d185af45
parent75f28df43800e697c243b4a1d7831ca0d88a2440 (diff)
downloadeclipse.platform.swt-01afcdc0fb8782ec7a80728fedb1495e0212ed01.tar.gz
eclipse.platform.swt-01afcdc0fb8782ec7a80728fedb1495e0212ed01.tar.xz
eclipse.platform.swt-01afcdc0fb8782ec7a80728fedb1495e0212ed01.zip
Bug 541415 - setLineVerticalIndent makes getTopPixel fail
Make setLineVerticalIndent reset the outdated verticalOffsetPixel when the indent affects the scroll location, so vertifactOffset gets recomputed later when necessary. Change-Id: Ie358297ec817a216bc4e3e09b8949f3b056598d4 Signed-off-by: Mickael Istria <mistria@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java3
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java13
2 files changed, 16 insertions, 0 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 0de126739e..ed4a25ac0c 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
@@ -9401,6 +9401,9 @@ public void setLineVerticalIndent(int lineIndex, int verticalLineIndent) {
}
setVariableLineHeight();
int oldBottom = getLinePixel(lineIndex + 1);
+ if (oldBottom <= getClientArea().height) {
+ verticalScrollOffset = -1;
+ }
renderer.setLineVerticalIndent(lineIndex, verticalLineIndent);
resetCache(lineIndex, 1);
int newBottom = getLinePixel(lineIndex + 1);
diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
index 7306481055..bd67ad325f 100644
--- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
+++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java
@@ -24,6 +24,8 @@ import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BidiSegmentListener;
@@ -4823,6 +4825,17 @@ public void test_setTopPixelI(){
}
@Test
+public void test_verticalIndent_changeRelativeBounds() {
+ String _5000lines = IntStream.range(1, 5001).mapToObj(n -> Integer.toString(n)).collect(Collectors.joining("\n"));
+ text.setText(_5000lines);
+ text.setSize(500, 200);
+ text.invokeAction(ST.TEXT_END);
+ text.setLineVerticalIndent(text.getContent().getLineCount() - 1, 10);
+ text.invokeAction(ST.TEXT_START);
+ assertEquals(0, text.getTopPixel());
+}
+
+@Test
public void test_setWordWrapZ(){
String testString = "Line1\nLine2";

Back to the top