Skip to content

Commit 521741a

Browse files
committed
Tell web tools which LSP server to send WrapWithTag requests to
1 parent fdbcebd commit 521741a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/Razor/src/Microsoft.CodeAnalysis.Razor.CohostingShared/RazorLSPConstants.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ namespace Microsoft.VisualStudio.Razor.LanguageClient;
55

66
internal static class RazorLSPConstants
77
{
8+
public const string WebToolsWrapWithTagServerNameProperty = "_wrap_with_tag_lsp_server_name";
9+
810
public const string RazorCSharpLanguageServerName = "Razor C# Language Server Client";
911

1012
public const string RazorLanguageServerName = "Razor Language Server Client";
1113

14+
public const string RoslynLanguageServerName = "Roslyn Language Server Client";
15+
1216
public const string CohostLanguageServerName = "Cohosted Razor Language Server Client";
1317

1418
public const string HtmlLanguageServerName = "HtmlDelegationLanguageServerClient";

src/Razor/src/Microsoft.VisualStudio.LanguageServices.Razor/RazorLSPTextViewConnectionListener.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Microsoft.VisualStudio.Language.Intellisense;
1212
using Microsoft.VisualStudio.OLE.Interop;
1313
using Microsoft.VisualStudio.Razor.Extensions;
14+
using Microsoft.VisualStudio.Razor.LanguageClient;
1415
using Microsoft.VisualStudio.Shell;
1516
using Microsoft.VisualStudio.Text;
1617
using Microsoft.VisualStudio.Text.Editor;
@@ -128,6 +129,15 @@ public void SubjectBuffersConnected(ITextView textView, ConnectionReason reason,
128129
{
129130
_activeTextViews.Add(textView);
130131

132+
if (!textView.TextBuffer.Properties.ContainsProperty(RazorLSPConstants.WebToolsWrapWithTagServerNameProperty))
133+
{
134+
// We have to tell web tools which language server to send requests to for this buffer, but that changes
135+
// if cohosting is enabled.
136+
textView.TextBuffer.Properties[RazorLSPConstants.WebToolsWrapWithTagServerNameProperty] = _featureOptions.UseRazorCohostServer
137+
? RazorLSPConstants.RoslynLanguageServerName
138+
: RazorLSPConstants.RazorLanguageServerName;
139+
}
140+
131141
// Initialize the user's options and start listening for changes.
132142
// We only want to attach the option changed event once so we don't receive multiple
133143
// notifications if there is more than one TextView active.

0 commit comments

Comments
 (0)