@@ -17,6 +17,7 @@ import { Widget } from 'vs/base/browser/ui/widget';
1717import { AnchorPosition } from 'vs/base/browser/ui/contextview/contextview' ;
1818import { IOpenerService } from 'vs/platform/opener/common/opener' ;
1919import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService' ;
20+ import { MarkdownString } from 'vs/base/common/htmlContent' ;
2021
2122const $ = dom . $ ;
2223
@@ -78,7 +79,8 @@ export class HoverWidget extends Widget {
7879
7980 const rowElement = $ ( 'div.hover-row.markdown-hover' ) ;
8081 const contentsElement = $ ( 'div.hover-contents' ) ;
81- const markdownElement = renderMarkdown ( options . text , {
82+ const markdown = typeof options . text === 'string' ? new MarkdownString ( options . text ) : options . text ;
83+ const markdownElement = renderMarkdown ( markdown , {
8284 actionHandler : {
8385 callback : ( content ) => this . _linkHandler ( content ) ,
8486 disposeables : this . _messageListeners
@@ -118,7 +120,20 @@ export class HoverWidget extends Widget {
118120 }
119121
120122 const mouseTrackerTargets = [ ...this . _target . targetElements ] ;
121- if ( ! options . hideOnHover || ( options . actions && options . actions . length > 0 ) ) {
123+ let hideOnHover : boolean ;
124+ if ( options . hideOnHover === undefined ) {
125+ if ( options . actions && options . actions . length > 0 ) {
126+ // If there are actions, require hover so they can be accessed
127+ hideOnHover = false ;
128+ } else {
129+ // Defaults to true when string, false when markdown as it may contain links
130+ hideOnHover = typeof options . text === 'string' ;
131+ }
132+ } else {
133+ // It's set explicitly
134+ hideOnHover = options . hideOnHover ;
135+ }
136+ if ( ! hideOnHover ) {
122137 mouseTrackerTargets . push ( this . _hover . containerDomNode ) ;
123138 }
124139 this . _mouseTracker = new CompositeMouseTracker ( mouseTrackerTargets ) ;
0 commit comments