mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-198297 Quick Documentation popup is sometimes placed off screen
prevent quick doc popup from splitting between screens - update fix to avoid NPE on showing popup
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user