@@ -27,7 +27,6 @@ export class RazorDocumentManager implements IRazorDocumentManager {
27
27
private readonly onRazorInitializedEmitter = new vscode . EventEmitter < void > ( ) ;
28
28
29
29
public razorDocumentGenerationInitialized = false ;
30
- private anyRazorDocumentOpen = false ;
31
30
32
31
constructor ( private readonly serverClient : RazorLanguageServerClient , private readonly logger : RazorLogger ) { }
33
32
@@ -156,7 +155,6 @@ export class RazorDocumentManager implements IRazorDocumentManager {
156
155
}
157
156
158
157
private async openDocument ( uri : vscode . Uri ) {
159
- this . anyRazorDocumentOpen = true ;
160
158
await this . ensureRazorInitialized ( ) ;
161
159
162
160
const document = this . _getDocument ( uri ) ;
@@ -165,12 +163,11 @@ export class RazorDocumentManager implements IRazorDocumentManager {
165
163
}
166
164
167
165
public async ensureRazorInitialized ( ) {
168
- // On first open of a Razor document, we kick off the generation of all razor documents so that
169
- // components are discovered correctly. If we do this early, when we initialize everything, we
170
- // just spend a lot of time generating documents and json files that might not be needed.
171
- // If we wait for each individual document to be opened by the user, then locally defined components
172
- // don't work, which is a poor experience. This is the compromise.
173
- if ( this . roslynActivated && ! this . razorDocumentGenerationInitialized && this . anyRazorDocumentOpen ) {
166
+ // Kick off the generation of all Razor documents so that components are
167
+ // discovered correctly. We need to do this even if a Razor file isn't
168
+ // open yet to handle the scenario where the user opens a C# file before
169
+ // a Razor file.
170
+ if ( this . roslynActivated && ! this . razorDocumentGenerationInitialized ) {
174
171
this . razorDocumentGenerationInitialized = true ;
175
172
vscode . commands . executeCommand ( razorInitializeCommand ) ;
176
173
for ( const document of this . documents ) {
0 commit comments