Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2019-02-26 18:00:27 +0000
committerMickael Istria2019-02-26 19:41:08 +0000
commit5f62a4a1adeb10f11945002f188bd16f4d3e2121 (patch)
treee486073f62a1736cfac3e5f4966f3b58d185af45
parent33ab81d8513fb320fbe759c8b766299f584d5c3f (diff)
downloadeclipse.platform.swt-5f62a4a1adeb10f11945002f188bd16f4d3e2121.tar.gz
eclipse.platform.swt-5f62a4a1adeb10f11945002f188bd16f4d3e2121.tar.xz
eclipse.platform.swt-5f62a4a1adeb10f11945002f188bd16f4d3e2121.zip
Revert "Revert "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. This reverts commit 33ab81d8513fb320fbe759c8b766299f584d5c3f. Change-Id: I62a23f7f538090477ab162e3df3889c0af5060e1
-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