@@ -33,7 +33,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
3333 public razorDocumentGenerationInitialized = false ;
3434
3535 constructor (
36- private readonly serverClient : RazorLanguageServerClient ,
36+ private readonly serverClient : RazorLanguageServerClient | undefined ,
3737 private readonly logger : RazorLogger ,
3838 private readonly telemetryReporter : TelemetryReporter ,
3939 private readonly platformInfo : PlatformInformation
@@ -128,13 +128,16 @@ export class RazorDocumentManager implements IRazorDocumentManager {
128128
129129 this . closeDocument ( document . uri ) ;
130130 } ) ;
131- this . serverClient . onNotification ( 'razor/updateCSharpBuffer' , async ( updateBufferRequest ) =>
132- this . updateCSharpBuffer ( updateBufferRequest )
133- ) ;
134131
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+ }
138141
139142 return vscode . Disposable . from ( watcher , didCreateRegistration , didOpenRegistration , didCloseRegistration ) ;
140143 }
@@ -163,6 +166,10 @@ export class RazorDocumentManager implements IRazorDocumentManager {
163166 }
164167
165168 public async ensureRazorInitialized ( ) {
169+ if ( this . serverClient === undefined ) {
170+ return ;
171+ }
172+
166173 // Kick off the generation of all Razor documents so that components are
167174 // discovered correctly. We need to do this even if a Razor file isn't
168175 // open yet to handle the scenario where the user opens a C# file before
0 commit comments