@@ -11,16 +11,20 @@ import {Position} from 'vs/editor/common/core/position';
1111import { IPosition , IConfigurationChangedEvent } from 'vs/editor/common/editorCommon' ;
1212import * as editorBrowser from 'vs/editor/browser/editorBrowser' ;
1313import { Widget } from 'vs/base/browser/ui/widget' ;
14+ import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement' ;
15+ import { IDisposable , dispose } from 'vs/base/common/lifecycle' ;
1416
1517export class ContentHoverWidget extends Widget implements editorBrowser . IContentWidget {
1618
1719 private _id : string ;
1820 protected _editor : editorBrowser . ICodeEditor ;
1921 private _isVisible : boolean ;
2022 private _containerDomNode : HTMLElement ;
21- protected _domNode : HTMLElement ;
23+ private _domNode : HTMLElement ;
2224 protected _showAtPosition : Position ;
2325 private _stoleFocus : boolean ;
26+ private scrollbar : DomScrollableElement ;
27+ private disposables : IDisposable [ ] = [ ] ;
2428
2529 // Editor.IContentWidget.allowEditorOverflow
2630 public allowEditorOverflow = true ;
@@ -42,11 +46,15 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
4246
4347 this . _containerDomNode = document . createElement ( 'div' ) ;
4448 this . _containerDomNode . className = 'monaco-editor-hover hidden' ;
49+ this . _containerDomNode . tabIndex = 0 ;
4550
4651 this . _domNode = document . createElement ( 'div' ) ;
4752 this . _domNode . className = 'monaco-editor-hover-content' ;
48- this . _containerDomNode . appendChild ( this . _domNode ) ;
49- this . _containerDomNode . tabIndex = 0 ;
53+
54+ this . scrollbar = new DomScrollableElement ( this . _domNode , { canUseTranslate3d : false } ) ;
55+ this . disposables . push ( this . scrollbar ) ;
56+ this . _containerDomNode . appendChild ( this . scrollbar . getDomNode ( ) ) ;
57+
5058 this . onkeydown ( this . _containerDomNode , ( e : IKeyboardEvent ) => {
5159 if ( e . equals ( CommonKeybindings . ESCAPE ) ) {
5260 this . hide ( ) ;
@@ -72,9 +80,6 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
7280 }
7381
7482 public showAt ( position :IPosition , focus : boolean ) : void {
75- // Update the font for the `code` class elements
76- this . updateFont ( ) ;
77-
7883 // Position has changed
7984 this . _showAtPosition = new Position ( position . lineNumber , position . column ) ;
8085 this . isVisible = true ;
@@ -117,6 +122,7 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
117122
118123 public dispose ( ) : void {
119124 this . _editor . removeContentWidget ( this ) ;
125+ this . disposables = dispose ( this . disposables ) ;
120126 super . dispose ( ) ;
121127 }
122128
@@ -126,6 +132,15 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
126132
127133 [ ...codeTags , ...codeClasses ] . forEach ( node => this . _editor . applyFontInfo ( node ) ) ;
128134 }
135+
136+ protected updateContents ( node : Node ) : void {
137+ this . _domNode . textContent = '' ;
138+ this . _domNode . appendChild ( node ) ;
139+ this . updateFont ( ) ;
140+
141+ this . _editor . layoutContentWidget ( this ) ;
142+ this . scrollbar . scanDomNode ( ) ;
143+ }
129144}
130145
131146export class GlyphHoverWidget extends Widget implements editorBrowser . IOverlayWidget {
0 commit comments