Skip to content

Commit c092aeb

Browse files
committed
fixing the error
1 parent 6353756 commit c092aeb

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,19 @@ export class ContentHoverWidget extends ResizableContentWidget {
721721
// See https://github.com/microsoft/vscode/issues/140339
722722
// TODO: Doing a second layout of the hover after force rendering the editor
723723
this.onContentsChanged();
724+
725+
// If the normal rendering dimensions surpass the resizable node max dimensions
726+
// then update the dimensions of the hover
727+
this._setResizableNodeMaxDimensions();
728+
const containerDomNode = this._hover.containerDomNode;
729+
const currentHeight = containerDomNode.clientHeight;
730+
const currentWidth = containerDomNode.clientWidth;
731+
const maxHeight = Math.min(this._resizableNode.maxSize.height, currentHeight);
732+
const maxWidth = Math.min(this._resizableNode.maxSize.width, currentWidth);
733+
if (currentHeight >= maxHeight || currentWidth >= maxWidth) {
734+
this._layoutWidget(maxHeight, maxWidth);
735+
}
736+
724737
if (hoverData.stoleFocus) {
725738
this._hover.containerDomNode.focus();
726739
}
@@ -757,12 +770,8 @@ export class ContentHoverWidget extends ResizableContentWidget {
757770
this._setContentsDomNodeDimensions(dom.getTotalWidth(contentsDomNode), Math.min(maxRenderingHeight, height - SCROLLBAR_WIDTH));
758771
}
759772

760-
public onContentsChanged(): void {
761-
this._removeConstraintsRenderNormally();
773+
private _layoutWidget(height: number, width: number) {
762774
const containerDomNode = this._hover.containerDomNode;
763-
764-
let height = dom.getTotalHeight(containerDomNode);
765-
let width = dom.getTotalWidth(containerDomNode);
766775
this._resizableNode.layout(height, width);
767776

768777
this._setHoverWidgetDimensions(width, height);
@@ -778,6 +787,12 @@ export class ContentHoverWidget extends ResizableContentWidget {
778787
this._layoutContentWidget();
779788
}
780789

790+
public onContentsChanged(): void {
791+
this._removeConstraintsRenderNormally();
792+
const containerDomNode = this._hover.containerDomNode;
793+
this._layoutWidget(dom.getTotalHeight(containerDomNode), dom.getTotalWidth(containerDomNode));
794+
}
795+
781796
public focus(): void {
782797
this._hover.containerDomNode.focus();
783798
}

0 commit comments

Comments
 (0)