From 2f1950f1c7d5b9997ffc9e8a715e6c288c0e3a2e Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Tue, 29 Oct 2013 16:20:56 +0400 Subject: [PATCH] IDEA-115561 Appearance of vertical and horizontal scroll bars in the search results is unexpected often --- .../ide/actions/SearchEverywhereAction.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java index 260e74e27d43..2c01b0480bad 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -1506,7 +1506,36 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA } private void adjustPopup() { - new PopupPositionManager.PositionAdjuster(getField().getParent(), 0).adjust(myPopup, PopupPositionManager.Position.BOTTOM); +// new PopupPositionManager.PositionAdjuster(getField().getParent(), 0).adjust(myPopup, PopupPositionManager.Position.BOTTOM); + final Dimension d = PopupPositionManager.PositionAdjuster.getPopupSize(myPopup); + final JComponent myRelativeTo = myBalloon.getContent(); + Point myRelativeOnScreen = myRelativeTo.getLocationOnScreen(); + Rectangle screen = ScreenUtil.getScreenRectangle(myRelativeOnScreen); + Rectangle popupRect = null; + Rectangle r = new Rectangle(myRelativeOnScreen.x, myRelativeOnScreen.y + myRelativeTo.getHeight(), d.width, d.height); + + if (screen.contains(r)) { + popupRect = r; + } + + if (popupRect != null) { + myPopup.setLocation(new Point(r.x, r.y)); + } + else { + if (r.y + d.height > screen.y + screen.height) { + r.height = screen.y + screen.height - r.y - 2; + } + if (r.width > screen.width) { + r.width = screen.width - 50; + } + if (r.x + r.width > screen.x + screen.width) { + r.x = screen.x + screen.width - r.width - 2; + } + + myPopup.setSize(r.getSize()); + myPopup.setLocation(r.getLocation()); + } + } private static boolean isToolWindowAction(Object o) {