From 61768dd15317a9e077b0180198a23177d4cb3eb8 Mon Sep 17 00:00:00 2001 From: aniketsahu07 Date: Fri, 22 May 2026 16:17:14 +0530 Subject: [PATCH 1/3] Fix: reserve dropdown popup scrollbar width to avoid suffix text cropping on GTK/Linux --- .../com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java index 7b9dc2f0..73385eac 100644 --- a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java +++ b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java @@ -156,6 +156,12 @@ void open(Point location, List groups, String selectedItemId, populateGroups(container, groups); Point contentSize = container.computeSize(SWT.DEFAULT, SWT.DEFAULT); + int scrollBarWidth = 0; + if (scrolledComposite.getVerticalBar() != null) { + scrollBarWidth = scrolledComposite.getVerticalBar().getSize().x; + } + // Reserve space for the vertical scrollbar to avoid cropping suffix text on GTK/Linux + contentSize.x += scrollBarWidth; container.setSize(contentSize); scrolledComposite.setMinSize(contentSize); From 4c3065f471c8fe685b8c07a0309ef0d0ae3c1c46 Mon Sep 17 00:00:00 2001 From: aniketsahu07 Date: Sun, 24 May 2026 07:59:05 +0530 Subject: [PATCH 2/3] Fix(review): avoid double-reserving scrollbar width; reserve only when constrained/scrollable --- .../microsoft/copilot/eclipse/ui/swt/DropdownPopup.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java index 73385eac..2937e9e2 100644 --- a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java +++ b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java @@ -156,12 +156,9 @@ void open(Point location, List groups, String selectedItemId, populateGroups(container, groups); Point contentSize = container.computeSize(SWT.DEFAULT, SWT.DEFAULT); - int scrollBarWidth = 0; - if (scrolledComposite.getVerticalBar() != null) { - scrollBarWidth = scrolledComposite.getVerticalBar().getSize().x; - } - // Reserve space for the vertical scrollbar to avoid cropping suffix text on GTK/Linux - contentSize.x += scrollBarWidth; + // Keep sizing simple here. If the popup becomes scrollable we reserve + // scrollbar width in constrainHeightIfNeeded(), avoiding double-reserving + // the width when the scrollbar is detected in both places. container.setSize(contentSize); scrolledComposite.setMinSize(contentSize); From f7fc555be5ece3cc3cb50819e44bdd51961c667e Mon Sep 17 00:00:00 2001 From: aniketsahu07 Date: Mon, 25 May 2026 07:46:34 +0530 Subject: [PATCH 3/3] Fix: reserve scrollbar width only when popup will be scrollable; avoid double-counting in constrainHeightIfNeeded() --- .../copilot/eclipse/ui/swt/DropdownPopup.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java index 2937e9e2..d29f10cd 100644 --- a/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java +++ b/com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/swt/DropdownPopup.java @@ -156,9 +156,23 @@ void open(Point location, List groups, String selectedItemId, populateGroups(container, groups); Point contentSize = container.computeSize(SWT.DEFAULT, SWT.DEFAULT); - // Keep sizing simple here. If the popup becomes scrollable we reserve - // scrollbar width in constrainHeightIfNeeded(), avoiding double-reserving - // the width when the scrollbar is detected in both places. + // If the popup will be scrollable, reserve space now for the vertical + // scrollbar so suffix text is not cropped. We detect the likely scrollable + // case by checking the item count against MAX_VISIBLE_ITEMS and reserve + // the scrollbar width here (so constrainHeightIfNeeded() does not need to + // also add it and double-count). + if (items.size() > MAX_VISIBLE_ITEMS && scrolledComposite.getVerticalBar() != null) { + int scrollBarWidth = scrolledComposite.getVerticalBar().getSize().x; + if (scrollBarWidth == 0) { + // computeSize may return a value even if getSize is not yet populated + scrollBarWidth = scrolledComposite.getVerticalBar().computeSize(SWT.DEFAULT, SWT.DEFAULT).x; + } + if (scrollBarWidth == 0) { + // Fallback to a conservative default if the widget can't report size yet + scrollBarWidth = 16; + } + contentSize.x += scrollBarWidth; + } container.setSize(contentSize); scrolledComposite.setMinSize(contentSize); @@ -236,15 +250,11 @@ private void constrainHeightIfNeeded() { Composite lastVisible = items.get(lastIdx).composite(); Rectangle lastBounds = lastVisible.getBounds(); int maxContentHeight = lastBounds.y + lastBounds.height; - - int scrollBarWidth = 0; - if (scrolledComposite.getVerticalBar() != null) { - scrollBarWidth = scrolledComposite.getVerticalBar().getSize().x; - } - Point shellSize = shell.getSize(); int newHeight = maxContentHeight + 2 * POPUP_MARGIN; - shell.setSize(shellSize.x + scrollBarWidth, newHeight); + // Width already reserved when we detected the popup would be scrollable + // during initial sizing in open(). Only adjust the height here. + shell.setSize(shellSize.x, newHeight); } private void adjustBounds(Point location, int anchorHeight) {