Skip to content

Commit 31f7511

Browse files
authored
Merge pull request microsoft#187586 from microsoft/aiday/contentHoverMinimumDimensions
Set content hover minimum dimensions
2 parents 02d3b49 + bc44929 commit 31f7511

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

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

Lines changed: 8 additions & 2 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 minimumHeight = this._editor.getOption(EditorOption.lineHeight) + 8;
56+
const minimumWidth = 4 / 3 * minimumHeight;
57+
const minimumSize = new dom.Dimension(minimumWidth, minimumHeight);
58+
this._widget = this._register(this._instantiationService.createInstance(ContentHoverWidget, this._editor, minimumSize));
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()) {
@@ -490,9 +495,10 @@ export class ContentHoverWidget extends ResizableContentWidget {
490495

491496
constructor(
492497
editor: ICodeEditor,
498+
minimumSize: dom.Dimension,
493499
@IContextKeyService contextKeyService: IContextKeyService
494500
) {
495-
super(editor);
501+
super(editor, minimumSize);
496502
this._hoverVisibleKey = EditorContextKeys.hoverVisible.bindTo(contextKeyService);
497503
this._hoverFocusedKey = EditorContextKeys.hoverFocused.bindTo(contextKeyService);
498504

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ export abstract class ResizableContentWidget extends Disposable implements ICont
2525

2626
constructor(
2727
protected readonly _editor: ICodeEditor,
28-
initialSize: dom.IDimension = new dom.Dimension(10, 10)
28+
minimumSize: dom.IDimension = new dom.Dimension(10, 10)
2929
) {
3030
super();
3131
this._resizableNode.domNode.style.position = 'absolute';
32-
this._resizableNode.minSize = new dom.Dimension(10, 10);
32+
this._resizableNode.minSize = dom.Dimension.lift(minimumSize);
33+
this._resizableNode.layout(minimumSize.height, minimumSize.width);
3334
this._resizableNode.enableSashes(true, true, true, true);
34-
this._resizableNode.layout(initialSize.height, initialSize.width);
3535
this._register(this._resizableNode.onDidResize(e => {
3636
this._resize(new dom.Dimension(e.dimension.width, e.dimension.height));
3737
if (e.done) {

0 commit comments

Comments
 (0)