@@ -618,10 +618,11 @@ export class ContentHoverWidget extends ResizableContentWidget {
618
618
if ( ! this . _editor || ! this . _editor . hasModel ( ) ) {
619
619
return ;
620
620
}
621
- const editorBox = dom . getDomNodePagePosition ( this . _editor . getDomNode ( ) ) ;
622
- const glyphMarginWidth = this . _editor . getLayoutInfo ( ) . glyphMarginWidth ;
623
- const leftOfContainer = this . _hover . containerDomNode . offsetLeft ;
624
- return editorBox . width + editorBox . left - leftOfContainer - glyphMarginWidth ;
621
+ const editorLayoutInfo = this . _editor . getLayoutInfo ( ) ;
622
+ const glyphMarginRight = editorLayoutInfo . glyphMarginLeft + editorLayoutInfo . glyphMarginWidth ;
623
+ const cursorPosition = this . _editor . _getViewModel ( ) . getPrimaryCursorState ( ) . viewState . position ;
624
+ const bodyBoxWidth = dom . getClientArea ( document . body ) . width ;
625
+ return bodyBoxWidth - glyphMarginRight - this . _editor . getOffsetForColumn ( cursorPosition . lineNumber , cursorPosition . column ) ;
625
626
}
626
627
627
628
public isMouseGettingCloser ( posx : number , posy : number ) : boolean {
@@ -721,19 +722,6 @@ export class ContentHoverWidget extends ResizableContentWidget {
721
722
// See https://github.com/microsoft/vscode/issues/140339
722
723
// TODO: Doing a second layout of the hover after force rendering the editor
723
724
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
-
737
725
if ( hoverData . stoleFocus ) {
738
726
this . _hover . containerDomNode . focus ( ) ;
739
727
}
@@ -770,8 +758,12 @@ export class ContentHoverWidget extends ResizableContentWidget {
770
758
this . _setContentsDomNodeDimensions ( dom . getTotalWidth ( contentsDomNode ) , Math . min ( maxRenderingHeight , height - SCROLLBAR_WIDTH ) ) ;
771
759
}
772
760
773
- private _layoutWidget ( height : number , width : number ) {
761
+ public onContentsChanged ( ) : void {
762
+ this . _removeConstraintsRenderNormally ( ) ;
774
763
const containerDomNode = this . _hover . containerDomNode ;
764
+
765
+ let height = dom . getTotalHeight ( containerDomNode ) ;
766
+ let width = dom . getTotalWidth ( containerDomNode ) ;
775
767
this . _resizableNode . layout ( height , width ) ;
776
768
777
769
this . _setHoverWidgetDimensions ( width , height ) ;
@@ -787,12 +779,6 @@ export class ContentHoverWidget extends ResizableContentWidget {
787
779
this . _layoutContentWidget ( ) ;
788
780
}
789
781
790
- public onContentsChanged ( ) : void {
791
- this . _removeConstraintsRenderNormally ( ) ;
792
- const containerDomNode = this . _hover . containerDomNode ;
793
- this . _layoutWidget ( dom . getTotalHeight ( containerDomNode ) , dom . getTotalWidth ( containerDomNode ) ) ;
794
- }
795
-
796
782
public focus ( ) : void {
797
783
this . _hover . containerDomNode . focus ( ) ;
798
784
}
0 commit comments