@@ -65,7 +65,7 @@ type internal QuickInfoViewProvider
6565|> typeMap.Value.GetClassificationType
6666|> formatMap.Value.GetTextProperties
6767
68- let formatText ( navigation : QuickInfoNavigation ) ( content : seq < Layout.TaggedText >) : IDeferredQuickInfoContent =
68+ let formatText ( navigation : QuickInfoNavigation ) ( content : # seq<Layout.TaggedText> ) =
6969
7070let navigateAndDismiss range _ =
7171 navigation.NavigateTo range
@@ -78,43 +78,46 @@ type internal QuickInfoViewProvider
7878 t.Background<- Media.SolidColorBrush( Media.Color.FromRgb( color.R, color.G, color.B))
7979 t
8080
81- let inlines =
82- seq {
83- for taggedTextin contentdo
84- let run = Documents.Run taggedText.Text
85- let inl =
86- match taggedTextwith
87- | : ? Layout .NavigableTaggedText as nav when navigation .IsTargetValid nav .Range ->
88- let h = Documents.Hyperlink( run, ToolTip= secondaryToolTip nav.Range)
89- h.Click.Add<| navigateAndDismiss nav.Range
90- h:> Documents .Inline
91- | _ -> run:> _
92- DependencyObjectExtensions.SetTextProperties( inl, layoutTagToFormatting taggedText.Tag)
93- yield inl
94- }
95-
96- let createTextLinks () =
97- let tb = TextBlock( TextWrapping= TextWrapping.Wrap, TextTrimming= TextTrimming.None)
98- DependencyObjectExtensions.SetDefaultTextProperties( tb, formatMap.Value)
99- tb.Inlines.AddRange inlines
100- if tb.Inlines.Count= 0 then tb.Visibility<- Visibility.Collapsed
101- tb.Resources.[ typeof< Documents.Hyperlink>] <- getStyle()
102- tb:> FrameworkElement
103-
104- { new IDeferredQuickInfoContentwith member x.Create () = createTextLinks() }
105-
106- let empty =
107- { new IDeferredQuickInfoContentwith
108- member x.Create () = TextBlock( Visibility= Visibility.Collapsed) :> FrameworkElement }
81+ let toInline ( taggedText : Layout.TaggedText ) =
82+ let run = Documents.Run taggedText.Text
83+ let inl =
84+ match taggedTextwith
85+ | :? Layout.NavigableTaggedTextas navwhen navigation.IsTargetValid nav.Range->
86+ let h = Documents.Hyperlink( run, ToolTip= secondaryToolTip nav.Range)
87+ h.Click.Add<| navigateAndDismiss nav.Range
88+ h:> Documents.Inline
89+ | _ -> run:> _
90+ DependencyObjectExtensions.SetTextProperties( inl, layoutTagToFormatting taggedText.Tag)
91+ inl
92+
93+ let tb = TextBlock( TextWrapping= TextWrapping.Wrap, TextTrimming= TextTrimming.None)
94+ DependencyObjectExtensions.SetDefaultTextProperties( tb, formatMap.Value)
95+ tb.Inlines.AddRange( content|> Seq.map toInline)
96+ if tb.Inlines.Count= 0 then tb.Visibility<- Visibility.Collapsed
97+ tb.Resources.[ typeof< Documents.Hyperlink>] <- getStyle()
98+ tb
99+
100+ let wrap ( tb : TextBlock ) =
101+ // Formula to make max width of the TextBlock proportional to the tooltip font size.
102+ // We need it, because the ascii-art divider inserted into xml documentation is of variable length and could wrap otherwise
103+ let maxWidth = formatMap.Value.DefaultTextProperties.FontRenderingEmSize* 60.0
104+ tb.MaxWidth<- maxWidth
105+ tb.HorizontalAlignment<- HorizontalAlignment.Left
106+ tb
107+
108+ let defer toTextBlock layout =
109+ { new IDeferredQuickInfoContentwith member __.Create () = upcast toTextBlock layout}
109110
110111member __.ProvideContent ( glyph : Glyph , description , documentation , typeParameterMap , usage , exceptions , navigation : QuickInfoNavigation ) =
111- let navigableText x = formatText navigation x
112+ let navigable = defer( formatText navigation)
113+ let wrapped = defer( formatText navigation>> wrap)
114+ let empty = defer( fun () -> TextBlock( Visibility= Visibility.Collapsed)) ()
112115let glyphContent = SymbolGlyphDeferredContent( glyph, glyphService)
113116 QuickInfoDisplayDeferredContent
114117( glyphContent, null ,
115- mainDescription= navigableText description,
116- documentation= navigableText documentation,
117- typeParameterMap= navigableText typeParameterMap,
118+ mainDescription= navigable description,
119+ documentation= wrapped documentation,
120+ typeParameterMap= navigable typeParameterMap,
118121 anonymousTypes= empty,
119- usageText= navigableText usage,
120- exceptionText= navigableText exceptions)
122+ usageText= navigable usage,
123+ exceptionText= navigable exceptions)