From 93a300f3e646b2a0cd3cf9b766aae3b2e0b381bf Mon Sep 17 00:00:00 2001 From: Dennis Ushakov Date: Fri, 9 Feb 2018 17:19:43 +0300 Subject: [PATCH] reflow text to new width --- .../documentation/DocumentationComponent.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java index fe606ca05594..f606b57d3c4b 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/documentation/DocumentationComponent.java @@ -778,7 +778,6 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr myEditorPane.setCaretPosition(0); }}); } - private void showHint() { Editor editor = myManager.getEditor(); Component popupAnchor = getPopupAnchor(editor); @@ -789,9 +788,14 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr Dimension preferredSize = myEditorPane.getPreferredSize(); int width = definitionPreferredWidth(); width = width < 0 ? preferredSize.width : width; + width = Math.min(maxWidth, Math.max(JBUI.scale(300), width)); + myEditorPane.setBounds(0, 0, width, MAX_DEFAULT.height); + myEditorPane.setText(myEditorPane.getText()); + preferredSize = myEditorPane.getPreferredSize(); + int height = preferredSize.height + (needsToolbar() ? myControlPanel.getPreferredSize().height : 0); - hintSize = new Dimension(Math.min(maxWidth, Math.max(JBUI.scale(300), width)), - Math.min(MAX_DEFAULT.height, Math.max(MIN_DEFAULT.height, height))); + height = Math.min(MAX_DEFAULT.height, Math.max(MIN_DEFAULT.height, height)); + hintSize = new Dimension(width, height); } else { hintSize = DimensionService.getInstance().getSize(DocumentationManager.NEW_JAVADOC_LOCATION_AND_SIZE, myManager.myProject); hintSize = hintSize != null ? hintSize : MIN_DEFAULT; @@ -883,7 +887,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr } myIsShown = true; if (myHint.getDimensionServiceKey() == null) { - SwingUtilities.invokeLater(() -> registerSizeTracker()); + SwingUtilities.invokeLater(this::registerSizeTracker); } } }