Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2019-07-11 10:12:13 +0000
committerAndrey Loskutov2019-07-11 10:37:27 +0000
commit0bc87fc204a7f19137c97a7fdc15e8aee9b0c706 (patch)
tree54d326d1930ce546f11a7a8255615989a9afdcc5
parent00764c76d1ea7298c2ec9d7edde1acd75f22d5bd (diff)
downloadeclipse.platform.swt-0bc87fc204a7f19137c97a7fdc15e8aee9b0c706.tar.gz
eclipse.platform.swt-0bc87fc204a7f19137c97a7fdc15e8aee9b0c706.tar.xz
eclipse.platform.swt-0bc87fc204a7f19137c97a7fdc15e8aee9b0c706.zip
Revert "Bug 547532 - [StyledText] GlyphMetrics on tab alter bounds"
Reverting the original commit as it causes Bug 547532. This reverts commit 42e1162be185ee9d256a21b48da94cd1df2de7eb. Change-Id: Ia50a2815bf81e127b773cc59ed48672ee7054336
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java20
-rw-r--r--tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_custom_StyledText.java15
2 files changed, 2 insertions, 33 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
index d74730d752..98c43dbb3f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
@@ -1128,15 +1128,7 @@ TextLayout getTextLayout(int lineIndex, int orientation, int width, int lineSpac
if (lastOffset < start) {
layout.setStyle(null, lastOffset, start - 1);
}
- TextStyle style = getStyleRange(styles[i >> 1]);
- if (style.metrics != null && line.substring(start, Math.min(length, end + 1)).contains("\t")) {
- line =
- line.substring(0, start) +
- line.substring(start, end + 1).replace('\t', ' ') +
- (end < line.length() ? line.substring(end + 1, line.length()) : "");
- layout.setText(line);
- }
- layout.setStyle(style, start, end);
+ layout.setStyle(getStyleRange(styles[i >> 1]), start, end);
lastOffset = Math.max(lastOffset, end);
}
} else {
@@ -1153,15 +1145,7 @@ TextLayout getTextLayout(int lineIndex, int orientation, int width, int lineSpac
if (lastOffset < start) {
layout.setStyle(null, lastOffset, start - 1);
}
- TextStyle style = getStyleRange(styles[i]);
- if (style.metrics != null && line.substring(start, end + 1).contains("\t")) {
- line =
- line.substring(0, start) +
- line.substring(start, end + 1).replace('\t', ' ') +
- (end < line.length() ? line.substring(end + 1, line.length()) : "");
- layout.setText(line);
- }
- layout.setStyle(style, start, end);
+ layout.setStyle(getStyleRange(styles[i]), start, end);
lastOffset = Math.max(lastOffset, end);
}
}
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 2614882a52..ea07d58f73 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
@@ -5360,20 +5360,5 @@ public void test_consistency_DragDetect () {
consistencyEvent(30, 10, 50, 0, ConsistencyUtility.MOUSE_DRAG);
}
-@Test
-public void test_GlyphMetricsOnTab() {
- text.setTabs(4);
- text.setText("\tabcdefghijkl");
- Rectangle boundsWithoutGlyphMetrics = text.getTextBounds(0, text.getText().length() - 1);
- int tabWidthWithoutGlyphMetrics = text.getTextBounds(0, 0).width;
- StyleRange range = new StyleRange(0, 1, null, null);
- range.metrics = new GlyphMetrics(0, 0, 100);
- text.setStyleRange(range);
- int tabWidthWithGlyphMetrics = text.getTextBounds(0, 0).width;
- assertEquals(range.metrics.width, tabWidthWithGlyphMetrics);
- Rectangle boundsWithGlyphMetrics = text.getTextBounds(0, text.getText().length() - 1);
- assertEquals("Style should change text bounds", boundsWithoutGlyphMetrics.width - tabWidthWithoutGlyphMetrics + tabWidthWithGlyphMetrics, boundsWithGlyphMetrics.width);
-}
-
}

Back to the top