@@ -33,7 +33,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
33
33
public razorDocumentGenerationInitialized = false ;
34
34
35
35
constructor (
36
- private readonly serverClient : RazorLanguageServerClient ,
36
+ private readonly serverClient : RazorLanguageServerClient | undefined ,
37
37
private readonly logger : RazorLogger ,
38
38
private readonly telemetryReporter : TelemetryReporter ,
39
39
private readonly platformInfo : PlatformInformation
@@ -128,13 +128,16 @@ export class RazorDocumentManager implements IRazorDocumentManager {
128
128
129
129
this . closeDocument ( document . uri ) ;
130
130
} ) ;
131
- this . serverClient . onNotification ( 'razor/updateCSharpBuffer' , async ( updateBufferRequest ) =>
132
- this . updateCSharpBuffer ( updateBufferRequest )
133
- ) ;
134
131
135
- this . serverClient . onNotification ( 'razor/updateHtmlBuffer' , async ( updateBufferRequest ) =>
136
- this . updateHtmlBuffer ( updateBufferRequest )
137
- ) ;
132
+ if ( this . serverClient !== undefined ) {
133
+ this . serverClient . onNotification ( 'razor/updateCSharpBuffer' , async ( updateBufferRequest ) =>
134
+ this . updateCSharpBuffer ( updateBufferRequest )
135
+ ) ;
136
+
137
+ this . serverClient . onNotification ( 'razor/updateHtmlBuffer' , async ( updateBufferRequest ) =>
138
+ this . updateHtmlBuffer ( updateBufferRequest )
139
+ ) ;
140
+ }
138
141
139
142
return vscode . Disposable . from ( watcher , didCreateRegistration , didOpenRegistration , didCloseRegistration ) ;
140
143
}
@@ -163,6 +166,10 @@ export class RazorDocumentManager implements IRazorDocumentManager {
163
166
}
164
167
165
168
public async ensureRazorInitialized ( ) {
169
+ if ( this . serverClient === undefined ) {
170
+ return ;
171
+ }
172
+
166
173
// Kick off the generation of all Razor documents so that components are
167
174
// discovered correctly. We need to do this even if a Razor file isn't
168
175
// open yet to handle the scenario where the user opens a C# file before
0 commit comments