Skip to content
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

Set content hover minimum dimensions #187586

Merged
merged 3 commits into from
Jul 17, 2023
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
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 @@ -481,9 +486,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