Skip to content

Commit 01851f6

Browse files
committed
placing instead the minimum size determination as the initial size of the content hover when it is instantiated
1 parent d363a2f commit 01851f6

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/vs/editor/contrib/hover/browser/contentHover.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class ContentHoverController extends Disposable {
3030

3131
private readonly _participants: IEditorHoverParticipant[];
3232

33-
private readonly _widget = this._register(this._instantiationService.createInstance(ContentHoverWidget, this._editor));
33+
private readonly _widget: ContentHoverWidget;
3434

3535
getWidgetContent(): string | undefined {
3636
const node = this._widget.getDomNode();
@@ -52,6 +52,11 @@ export class ContentHoverController extends Disposable {
5252
) {
5353
super();
5454

55+
const initialHeight = this._editor.getOption(EditorOption.lineHeight) + 8;
56+
const initialWidth = 4 / 3 * initialHeight;
57+
const initialSize = new dom.Dimension(initialWidth, initialHeight);
58+
this._widget = this._register(this._instantiationService.createInstance(ContentHoverWidget, this._editor, initialSize));
59+
5560
// Instantiate participants and sort them by `hoverOrdinal` which is relevant for rendering order.
5661
this._participants = [];
5762
for (const participant of HoverParticipantRegistry.getAll()) {
@@ -481,9 +486,10 @@ export class ContentHoverWidget extends ResizableContentWidget {
481486

482487
constructor(
483488
editor: ICodeEditor,
489+
initialSize: dom.Dimension,
484490
@IContextKeyService contextKeyService: IContextKeyService
485491
) {
486-
super(editor);
492+
super(editor, initialSize);
487493
this._hoverVisibleKey = EditorContextKeys.hoverVisible.bindTo(contextKeyService);
488494
this._hoverFocusedKey = EditorContextKeys.hoverFocused.bindTo(contextKeyService);
489495

@@ -504,7 +510,6 @@ export class ContentHoverWidget extends ResizableContentWidget {
504510
this._hoverFocusedKey.set(false);
505511
}));
506512
this._setHoverData(undefined);
507-
this._setMinimumDimensions();
508513
this._layout();
509514
this._editor.addContentWidget(this);
510515
}
@@ -519,15 +524,6 @@ export class ContentHoverWidget extends ResizableContentWidget {
519524
return ContentHoverWidget.ID;
520525
}
521526

522-
private _setMinimumDimensions(): void {
523-
const width = 50;
524-
const height = this._editor.getOption(EditorOption.lineHeight) + 8;
525-
const contentsDomNode = this._hover.contentsDomNode;
526-
contentsDomNode.style.minWidth = width + 'px';
527-
contentsDomNode.style.minHeight = height + 'px';
528-
this._resizableNode.minSize = new dom.Dimension(width, height);
529-
}
530-
531527
private static _applyDimensions(container: HTMLElement, width: number | string, height: number | string): void {
532528
const transformedWidth = typeof width === 'number' ? `${width}px` : width;
533529
const transformedHeight = typeof height === 'number' ? `${height}px` : height;

0 commit comments

Comments
 (0)