Skip to content

Commit c8ddf0f

Browse files
ghentschkemickaelistria
authored andcommitted
[#2909] fix wrong hover size in composite hovers
These two changes require each other: * Do not add sizes in computeCompositeSize as only the max. should be used in x-direction * Prevent shrinking of the hover shell when the size calculation fails fixes #2909
1 parent ca63f41 commit c8ddf0f

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

bundles/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultInformationControl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ public void setVisible(boolean visible) {
368368

369369
@Override
370370
public Point computeSizeHint() {
371+
if (getShell().getChildren().length == 0) {
372+
// no content yet, return default size
373+
// computeSize would return 2,2 here
374+
return getShell().getSize();
375+
}
371376
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=117602
372377
int widthHint= SWT.DEFAULT;
373378
Point constraints= getSizeConstraints();

bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/hover/CompositeInformationControl.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ public IInformationControlCreator getInformationPresenterControlCreator() {
141141
LinkedHashMap<ITextHover, IInformationControlCreator> presenterCreators = new LinkedHashMap<>();
142142
boolean allNull = true;
143143
for (Entry<ITextHover, AbstractInformationControl> hover : this.controls.entrySet()) {
144-
IInformationControlCreator creator = hover.getValue()
145-
.getInformationPresenterControlCreator();
144+
IInformationControlCreator creator = hover.getValue().getInformationPresenterControlCreator();
146145
if (creator == null) {
147146
creator = this.creators.get(hover.getKey());
148147
} else {
@@ -174,8 +173,8 @@ public Point computeSizeHint() {
174173

175174
private Point computeCompositeSize(Function<AbstractInformationControl, Point> computeSize,
176175
Supplier<Point> getDefault) {
177-
return controls.values().stream().map(computeSize)
178-
.reduce((size1, size2) -> new Point(size1.x + size2.x, size1.y + size2.y + layout.verticalSpacing))
176+
return controls.values().stream().map(computeSize).reduce(
177+
(size1, size2) -> new Point(Math.max(size1.x, size2.x), size1.y + size2.y + layout.verticalSpacing))
179178
.orElseGet(getDefault);
180179
}
181180

bundles/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/markers/MarkerInformationControl.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ public IInformationControlCreator getInformationPresenterControlCreator() {
161161

162162
@Override
163163
public Point computeSizeHint() {
164-
getShell().pack();
164+
if (getShell().getChildren().length > 0) {
165+
// Do not pack the shell/control if it has no children, as it will size to 2,2
166+
getShell().pack();
167+
}
165168
return getShell().getSize();
166169
}
167170

0 commit comments

Comments
 (0)