@@ -11,6 +11,18 @@ open Microsoft.VisualStudio.Text.Adornments
1111open Microsoft.VisualStudio .Text .Editor
1212open Microsoft.VisualStudio .Utilities
1313
14+ module private Resources =
15+ let styles =
16+ #if DEBUG
17+ // load ResourceDictionary in a not 100% safe way for better debugging experience
18+ if ( isNull Application.ResourceAssembly) then
19+ Application.ResourceAssembly<- typeof< Microsoft.VisualStudio.FSharp.UIResources.QuickInfoOptionControl>. Assembly
20+ ResourceDictionary( Source= Uri( " HyperlinkStyles.xaml" , UriKind.Relative))
21+ else
22+ #endif
23+ ResourceDictionary( Source= Uri( @" /FSharp.UIResources;component/HyperlinkStyles.xaml" , UriKind.Relative))
24+
25+
1426[<Export( typeof< IViewElementFactory>) >]
1527[<Name( " NavigableTextRun to UIElement" ) >]
1628[<TypeConversion( typeof< NavigableTextRun>, typeof< UIElement>) >]
@@ -20,7 +32,6 @@ type WpfNavigableTextRunViewElementFactory
2032(
2133 viewElementFactoryService: IViewElementFactoryService
2234) =
23- let styles = ResourceDictionary( Source= Uri( @" /FSharp.UIResources;component/HyperlinkStyles.xaml" , UriKind.Relative))
2435interface IViewElementFactorywith
2536override __.CreateViewElement < 'TView when 'TView : not struct >( textView : ITextView , model : obj ) : 'TView =
2637if not ( model:? NavigableTextRun) || typeof< 'TView> <> typeof< UIElement> then
@@ -44,8 +55,17 @@ type WpfNavigableTextRunViewElementFactory
4455| QuickInfoUnderlineStyle.Dot-> " dot_underline"
4556else
4657" no_underline"
47- styles.[ key] :?> Style
48- tb.Resources.[ typeof< TextBlock>] <- underlineStyle
58+ Resources.styles.[ key] :?> Style
59+
60+ // we need to enclose the generated Inline, which is actually a Run element,
61+ // because fancy styling does not seem to work properly with Runs
62+ let inl = tb.Inlines.FirstInline
63+ let color = inl.Foreground
64+ // clear the color here to make it inherit
65+ inl.ClearValue( Documents.TextElement.ForegroundProperty) |> ignore
66+ // this constructor inserts into TextBlock
67+ Documents.Underline( tb.Inlines.FirstInline, tb.ContentStart, Foreground= color) |> ignore
68+ tb.Resources.[ typeof< Documents.Underline>] <- underlineStyle
4969| _ -> ()
5070
5171// add navigation