Skip to content

Commit fa193e6

Browse files
committed
Workaround for unexpected text wrapping
This commit adds one additional point to the width when calculating the minimum size of the textLabel in ExpandableComposite. This serves as a workaround for a current limitation in the SWT implementation on Windows. With certain zoom settings (e.g., 125% or 175%), depending on the length of the label text, the calculated width may be too small, causing the text to wrap unnecessarily. This is intended as a temporary workaround. Contributes to #2980
1 parent 208faf9 commit fa193e6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

bundles/org.eclipse.ui.forms/src/org/eclipse/ui/forms/widgets/ExpandableComposite.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import org.eclipse.core.runtime.Assert;
2424
import org.eclipse.core.runtime.ListenerList;
25+
import org.eclipse.core.runtime.Platform.OS;
2526
import org.eclipse.swt.SWT;
2627
import org.eclipse.swt.events.FocusEvent;
2728
import org.eclipse.swt.events.FocusListener;
@@ -287,7 +288,13 @@ protected void layout(Composite parent, boolean changed) {
287288
Point labelDefault = this.textLabelCache.computeSize(SWT.DEFAULT, SWT.DEFAULT);
288289

289290
int tcWidthBeforeSplit = Math.min(width, tcDefault.x);
290-
int labelWidthBeforeSplit = Math.min(width, labelDefault.x);
291+
292+
int additionalLabelWidthPadding = 0;
293+
if (OS.isWindows()) {
294+
/* compensate rounding issue in windows */
295+
additionalLabelWidthPadding = 1;
296+
}
297+
int labelWidthBeforeSplit = Math.min(width, labelDefault.x + additionalLabelWidthPadding);
291298

292299
int tcWidthAfterSplit = tcWidthBeforeSplit;
293300
int labelWidthAfterSplit = labelWidthBeforeSplit;

0 commit comments

Comments
 (0)