Skip to content

Commit

Permalink
Merge pull request #187586 from microsoft/aiday/contentHoverMinimumDi…
Browse files Browse the repository at this point in the history
…mensions

Set content hover minimum dimensions
  • Loading branch information
aiday-mar authored Jul 17, 2023
2 parents 02d3b49 + bc44929 commit 31f7511
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/vs/editor/contrib/hover/browser/contentHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ContentHoverController extends Disposable {

private readonly _participants: IEditorHoverParticipant[];

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

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

const minimumHeight = this._editor.getOption(EditorOption.lineHeight) + 8;
const minimumWidth = 4 / 3 * minimumHeight;
const minimumSize = new dom.Dimension(minimumWidth, minimumHeight);
this._widget = this._register(this._instantiationService.createInstance(ContentHoverWidget, this._editor, minimumSize));

// Instantiate participants and sort them by `hoverOrdinal` which is relevant for rendering order.
this._participants = [];
for (const participant of HoverParticipantRegistry.getAll()) {
Expand Down Expand Up @@ -490,9 +495,10 @@ export class ContentHoverWidget extends ResizableContentWidget {

constructor(
editor: ICodeEditor,
minimumSize: dom.Dimension,
@IContextKeyService contextKeyService: IContextKeyService
) {
super(editor);
super(editor, minimumSize);
this._hoverVisibleKey = EditorContextKeys.hoverVisible.bindTo(contextKeyService);
this._hoverFocusedKey = EditorContextKeys.hoverFocused.bindTo(contextKeyService);

Expand Down
6 changes: 3 additions & 3 deletions src/vs/editor/contrib/hover/browser/resizableContentWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export abstract class ResizableContentWidget extends Disposable implements ICont

constructor(
protected readonly _editor: ICodeEditor,
initialSize: dom.IDimension = new dom.Dimension(10, 10)
minimumSize: dom.IDimension = new dom.Dimension(10, 10)
) {
super();
this._resizableNode.domNode.style.position = 'absolute';
this._resizableNode.minSize = new dom.Dimension(10, 10);
this._resizableNode.minSize = dom.Dimension.lift(minimumSize);
this._resizableNode.layout(minimumSize.height, minimumSize.width);
this._resizableNode.enableSashes(true, true, true, true);
this._resizableNode.layout(initialSize.height, initialSize.width);
this._register(this._resizableNode.onDidResize(e => {
this._resize(new dom.Dimension(e.dimension.width, e.dimension.height));
if (e.done) {
Expand Down

0 comments on commit 31f7511

Please sign in to comment.