Skip to content

[#2909] fix wrong hover size in composite hovers #3056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ public void setVisible(boolean visible) {

@Override
public Point computeSizeHint() {
if (getShell().getChildren().length == 0) {
// no content yet, return default size
// computeSize would return 2,2 here
return getShell().getSize();
}
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=117602
int widthHint= SWT.DEFAULT;
Point constraints= getSizeConstraints();
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.ui.genericeditor/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.ui.genericeditor;singleton:=true
Bundle-Version: 1.3.600.qualifier
Bundle-Version: 1.3.700.qualifier
Bundle-Vendor: %Bundle-Vendor
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.ui.workbench.texteditor;bundle-version="3.10.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,7 @@ public IInformationControlCreator getInformationPresenterControlCreator() {
LinkedHashMap<ITextHover, IInformationControlCreator> presenterCreators = new LinkedHashMap<>();
boolean allNull = true;
for (Entry<ITextHover, AbstractInformationControl> hover : this.controls.entrySet()) {
IInformationControlCreator creator = hover.getValue()
.getInformationPresenterControlCreator();
IInformationControlCreator creator = hover.getValue().getInformationPresenterControlCreator();
if (creator == null) {
creator = this.creators.get(hover.getKey());
} else {
Expand Down Expand Up @@ -174,9 +173,14 @@ public Point computeSizeHint() {

private Point computeCompositeSize(Function<AbstractInformationControl, Point> computeSize,
Supplier<Point> getDefault) {
return controls.values().stream().map(computeSize)
.reduce((size1, size2) -> new Point(size1.x + size2.x, size1.y + size2.y + layout.verticalSpacing))
.orElseGet(getDefault);
return controls.values().stream().map(computeSize).reduce(
(size1, size2) -> new Point(Math.max(size1.x, size2.x), size1.y + size2.y + layout.verticalSpacing))
.map(size -> {
var shellSize = getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
int width = Math.max(size.x, shellSize.x);
int height = Math.max(size.y, shellSize.y);
return new Point(width, height);
}).orElseGet(getDefault);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,10 @@ public IInformationControlCreator getInformationPresenterControlCreator() {

@Override
public Point computeSizeHint() {
getShell().pack();
if (getShell().getChildren().length > 0) {
// Do not pack the shell/control if it has no children, as it will size to 2,2
getShell().pack();
}
return getShell().getSize();
}

Expand Down
Loading