diff --git a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java index d9c1127900f4..4d4dc13fedee 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/AbstractPopup.java @@ -509,7 +509,7 @@ public class AbstractPopup implements JBPopup { RelativePoint location = JBPopupFactory.getInstance().guessBestPopupLocation(dataContext); if (myLocateWithinScreen) { Point screenPoint = location.getScreenPoint(); - Rectangle rectangle = new Rectangle(screenPoint, getSize()); + Rectangle rectangle = new Rectangle(screenPoint, getSizeForPositioning()); Rectangle screen = ScreenUtil.getScreenRectangle(screenPoint); ScreenUtil.moveToFit(rectangle, screen, null); location = new RelativePoint(rectangle.getLocation()).getPointOn(location.getComponent()); @@ -517,6 +517,17 @@ public class AbstractPopup implements JBPopup { return location; } + private Dimension getSizeForPositioning() { + Dimension size = getSize(); + if (size == null && myDimensionServiceKey != null) { + size = DimensionService.getInstance().getSize(myDimensionServiceKey, myProject); + } + if (size == null) { + size = myContent.getPreferredSize(); + } + return size; + } + @Override public void showInBestPositionFor(@NotNull Editor editor) { assert editor.getComponent().isShowing() : "Editor must be showing on the screen";