Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit11f2ae3

Browse files
authored
Merge pull request #3030 from majocha/wrap-tooltip
Wrap xml docs in tooltip
2 parents6de8ece +06a694f commit11f2ae3

File tree

2 files changed

+43
-36
lines changed

2 files changed

+43
-36
lines changed

‎vsintegration/src/FSharp.Editor/QuickInfo/QuickInfoProvider.fs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,11 @@ type internal FSharpQuickInfoProvider
216216
|> Seq.map(fun x-> x.Text.Length)
217217
|> Seq.max
218218

219-
letseperator= TaggedTextOps.tag Text(String.replicate width"-")
219+
// eyeballed formula returning separator width in chars such as to prevent it from wrapping
220+
// will not be needed once we replace the ascii-art divider with a XAML element
221+
letwidth=if width/2>85then85else width/2
222+
223+
letseperator= TaggedTextOps.tag Text(String.replicate width"")
220224
letlineBreak= TaggedTextOps.tag LineBreak"\n"
221225

222226
// get whitespace nomalized documentation text

‎vsintegration/src/FSharp.Editor/QuickInfo/Views.fs‎

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type internal QuickInfoViewProvider
6565
|> typeMap.Value.GetClassificationType
6666
|> formatMap.Value.GetTextProperties
6767

68-
letformatText(navigation:QuickInfoNavigation)(content:seq<Layout.TaggedText>):IDeferredQuickInfoContent=
68+
letformatText(navigation:QuickInfoNavigation)(content:#seq<Layout.TaggedText>)=
6969

7070
letnavigateAndDismiss 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-
letinlines=
82-
seq{
83-
for taggedTextin contentdo
84-
letrun= Documents.Run taggedText.Text
85-
letinl=
86-
match taggedTextwith
87-
|:? Layout.NavigableTaggedText as nav when navigation.IsTargetValid nav.Range->
88-
leth= 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-
letcreateTextLinks()=
97-
lettb= TextBlock(TextWrapping= TextWrapping.Wrap, TextTrimming= TextTrimming.None)
98-
DependencyObjectExtensions.SetDefaultTextProperties(tb, formatMap.Value)
99-
tb.Inlines.AddRange inlines
100-
if tb.Inlines.Count=0then tb.Visibility<- Visibility.Collapsed
101-
tb.Resources.[typeof<Documents.Hyperlink>]<- getStyle()
102-
tb:> FrameworkElement
103-
104-
{new IDeferredQuickInfoContentwithmemberx.Create()= createTextLinks()}
105-
106-
letempty=
107-
{new IDeferredQuickInfoContentwith
108-
memberx.Create()= TextBlock(Visibility= Visibility.Collapsed):> FrameworkElement}
81+
lettoInline(taggedText:Layout.TaggedText)=
82+
letrun= Documents.Run taggedText.Text
83+
letinl=
84+
match taggedTextwith
85+
|:? Layout.NavigableTaggedTextas navwhen navigation.IsTargetValid nav.Range->
86+
leth= 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+
lettb= 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=0then tb.Visibility<- Visibility.Collapsed
97+
tb.Resources.[typeof<Documents.Hyperlink>]<- getStyle()
98+
tb
99+
100+
letwrap(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+
letmaxWidth= formatMap.Value.DefaultTextProperties.FontRenderingEmSize*60.0
104+
tb.MaxWidth<- maxWidth
105+
tb.HorizontalAlignment<- HorizontalAlignment.Left
106+
tb
107+
108+
letdefer toTextBlock layout=
109+
{new IDeferredQuickInfoContentwithmember__.Create()=upcast toTextBlock layout}
109110

110111
member__.ProvideContent(glyph:Glyph,description,documentation,typeParameterMap,usage,exceptions,navigation:QuickInfoNavigation)=
111-
letnavigableText x= formatText navigation x
112+
letnavigable= defer(formatText navigation)
113+
letwrapped= defer(formatText navigation>> wrap)
114+
letempty= defer(fun()-> TextBlock(Visibility= Visibility.Collapsed))()
112115
letglyphContent= 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)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp