From a6352965a8955328097ad31c889cbd9ea088ed8b Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Mon, 2 Jun 2014 16:28:15 +0200 Subject: [PATCH] fix popup width jumping --- .../com/intellij/ide/actions/SearchEverywhereAction.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 c4d34f7e9b05..a3cb1764451d 100644 --- a/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java +++ b/platform/lang-impl/src/com/intellij/ide/actions/SearchEverywhereAction.java @@ -126,6 +126,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA private static final int MAX_ACTIONS = 5; private static final int MAX_RECENT_FILES = 10; public static final int MAX_SEARCH_EVERYWHERE_HISTORY = 50; + private static final int POPUP_MAX_WIDTH = 600; private SearchEverywhereAction.MyListRenderer myRenderer; MySearchTextField myPopupField; @@ -346,7 +347,7 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA @Override public Dimension getPreferredSize() { final Dimension size = super.getPreferredSize(); - return new Dimension(Math.min(size.width - 2, 800), size.height); + return new Dimension(Math.min(size.width - 2, POPUP_MAX_WIDTH), size.height); } }; myList.setCellRenderer(myRenderer); @@ -1920,17 +1921,18 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA size.height = 70; } Dimension sz = new Dimension(size.width, myList.getPreferredSize().height); - if (sz.width > 800 || sz.height > 800) { + if (sz.width > POPUP_MAX_WIDTH || sz.height > POPUP_MAX_WIDTH) { final JBScrollPane pane = new JBScrollPane(); final int extraWidth = pane.getVerticalScrollBar().getWidth() + 1; final int extraHeight = pane.getHorizontalScrollBar().getHeight() + 1; - sz = new Dimension(Math.min(800, Math.max(getField().getWidth(), sz.width + extraWidth)), Math.min(800, sz.height + extraHeight)); + sz = new Dimension(Math.min(POPUP_MAX_WIDTH, Math.max(getField().getWidth(), sz.width + extraWidth)), Math.min(POPUP_MAX_WIDTH, sz.height + extraHeight)); sz.width += 20; sz.height+=2; } else { sz.width+=2; sz.height+=2; } + sz.width = Math.max(sz.width, myPopup.getSize().width); myPopup.setSize(sz); if (myActionEvent != null && myActionEvent.getInputEvent() == null) { final Point p = parent.getLocationOnScreen();