|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | 3 |
|
| 4 | +using System; |
4 | 5 | using System.Collections.Immutable; |
5 | 6 | using System.Composition; |
6 | 7 | using System.Threading; |
@@ -97,41 +98,43 @@ public ImmutableArray<Registration> GetRegistrations(VSInternalClientCapabilitie |
97 | 98 | static markupContent => markupContent.Value |
98 | 99 | ); |
99 | 100 |
|
100 | | - if (htmlStringResponse is not null) |
| 101 | + if (htmlStringResponse is null) |
101 | 102 | { |
102 | | - // This logic is to prepend HTML hover content to the razor hover content if both exist. |
103 | | - // The razor content comes through as a ContainerElement, while the html content comes |
104 | | - // through as MarkupContent. We need to extract the html content and insert it at the |
105 | | - // start of the combined ContainerElement. |
106 | | - if (razorHover is VSInternalHover razorVsInternalHover |
107 | | - && razorVsInternalHover.RawContent is ContainerElement razorContainerElement) |
108 | | - { |
109 | | - var htmlStringClassifiedTextElement = ClassifiedTextElement.CreatePlainText(htmlStringResponse); |
110 | | - var verticalSpacingTextElement = ClassifiedTextElement.CreatePlainText(string.Empty); |
111 | | - var htmlContainerElement = new ContainerElement( |
112 | | - ContainerElementStyle.Stacked, |
113 | | - [htmlStringClassifiedTextElement, verticalSpacingTextElement]); |
114 | | - |
115 | | - // Modify the existing hover's RawContent to prepend the HTML content. |
116 | | - razorVsInternalHover.RawContent = new ContainerElement(razorContainerElement.Style, [htmlContainerElement, .. razorContainerElement.Elements]); |
117 | | - } |
118 | | - else |
| 103 | + return razorHover; |
| 104 | + } |
| 105 | + |
| 106 | + // This logic is to prepend HTML hover content to the razor hover content if both exist. |
| 107 | + // The razor content comes through as a ContainerElement, while the html content comes |
| 108 | + // through as MarkupContent. We need to extract the html content and insert it at the |
| 109 | + // start of the combined ContainerElement. |
| 110 | + if (razorHover is VSInternalHover razorVsInternalHover |
| 111 | + && razorVsInternalHover.RawContent is ContainerElement razorContainerElement) |
| 112 | + { |
| 113 | + var htmlStringClassifiedTextElement = ClassifiedTextElement.CreatePlainText(htmlStringResponse); |
| 114 | + var verticalSpacingTextElement = ClassifiedTextElement.CreatePlainText(string.Empty); |
| 115 | + var htmlContainerElement = new ContainerElement( |
| 116 | + ContainerElementStyle.Stacked, |
| 117 | + [htmlStringClassifiedTextElement, verticalSpacingTextElement]); |
| 118 | + |
| 119 | + // Modify the existing hover's RawContent to prepend the HTML content. |
| 120 | + razorVsInternalHover.RawContent = new ContainerElement(razorContainerElement.Style, [htmlContainerElement, .. razorContainerElement.Elements]); |
| 121 | + } |
| 122 | + else |
| 123 | + { |
| 124 | + var razorStringResponse = razorHover.Contents.Match( |
| 125 | + static s => s, |
| 126 | + static markedString => throw new NotImplementedException(), |
| 127 | + static stringOrMarkedStringArray => throw new NotImplementedException(), |
| 128 | + static markupContent => markupContent.Value |
| 129 | + ); |
| 130 | + |
| 131 | + if (razorStringResponse is not null) |
119 | 132 | { |
120 | | - var razorStringResponse = razorHover.Contents.Match( |
121 | | - static s => s, |
122 | | - static markedString => null, |
123 | | - static stringOrMarkedStringArray => null, |
124 | | - static markupContent => markupContent.Value |
125 | | - ); |
126 | | - |
127 | | - if (razorStringResponse is not null) |
| 133 | + razorHover.Contents = new MarkupContent() |
128 | 134 | { |
129 | | - razorHover.Contents = new MarkupContent() |
130 | | - { |
131 | | - Kind = MarkupKind.Markdown, |
132 | | - Value = htmlStringResponse + "\n\n---\n\n" + razorStringResponse |
133 | | - }; |
134 | | - } |
| 135 | + Kind = MarkupKind.Markdown, |
| 136 | + Value = htmlStringResponse + "\n\n---\n\n" + razorStringResponse |
| 137 | + }; |
135 | 138 | } |
136 | 139 | } |
137 | 140 |
|
|
0 commit comments