@@ -455,6 +455,7 @@ const CONTAINER_HEIGHT_PADDING = 6;
455455export class ContentHoverWidget extends ResizableContentWidget {
456456
457457 public static ID = 'editor.contrib.resizableContentHoverWidget' ;
458+ private static _lastDimensions : dom . Dimension = new dom . Dimension ( 0 , 0 ) ;
458459
459460 private _visibleData : ContentHoverVisibleData | undefined ;
460461 private _positionPreference : ContentWidgetPositionPreference | undefined ;
@@ -578,6 +579,7 @@ export class ContentHoverWidget extends ResizableContentWidget {
578579 }
579580
580581 protected override _resize ( size : dom . Dimension ) : void {
582+ ContentHoverWidget . _lastDimensions = new dom . Dimension ( size . width , size . height ) ;
581583 this . _setAdjustedHoverWidgetDimensions ( size ) ;
582584 this . _resizableNode . layout ( size . height , size . width ) ;
583585 this . _setResizableNodeMaxDimensions ( ) ;
@@ -650,12 +652,13 @@ export class ContentHoverWidget extends ResizableContentWidget {
650652 }
651653
652654 private _layout ( ) : void {
653- const height = Math . max ( this . _editor . getLayoutInfo ( ) . height / 4 , 250 ) ;
655+ const height = Math . max ( this . _editor . getLayoutInfo ( ) . height / 4 , 250 , ContentHoverWidget . _lastDimensions . height ) ;
656+ const width = Math . max ( this . _editor . getLayoutInfo ( ) . width * 0.66 , 500 , ContentHoverWidget . _lastDimensions . width ) ;
654657 const { fontSize, lineHeight } = this . _editor . getOption ( EditorOption . fontInfo ) ;
655658 const contentsDomNode = this . _hover . contentsDomNode ;
656659 contentsDomNode . style . fontSize = `${ fontSize } px` ;
657660 contentsDomNode . style . lineHeight = `${ lineHeight / fontSize } ` ;
658- this . _setContentsDomNodeMaxDimensions ( Math . max ( this . _editor . getLayoutInfo ( ) . width * 0.66 , 500 ) , height ) ;
661+ this . _setContentsDomNodeMaxDimensions ( width , height ) ;
659662 }
660663
661664 private _updateFont ( ) : void {
@@ -676,8 +679,8 @@ export class ContentHoverWidget extends ResizableContentWidget {
676679 }
677680
678681 private _updateContentsDomNodeMaxDimensions ( ) {
679- const width = Math . max ( this . _editor . getLayoutInfo ( ) . width * 0.66 , 500 ) ;
680- const height = Math . max ( this . _editor . getLayoutInfo ( ) . height / 4 , 250 ) ;
682+ const height = Math . max ( this . _editor . getLayoutInfo ( ) . height / 4 , 250 , ContentHoverWidget . _lastDimensions . height ) ;
683+ const width = Math . max ( this . _editor . getLayoutInfo ( ) . width * 0.66 , 500 , ContentHoverWidget . _lastDimensions . width ) ;
681684 this . _setContentsDomNodeMaxDimensions ( width , height ) ;
682685 }
683686
0 commit comments