@@ -33,7 +33,19 @@ type UriString = string;
3333const VerificationDelay = 5 * 1000 ;
3434
3535let _verifyTimeout : NodeJS . Timeout | undefined ;
36- let _documentUriToVerify : vscode . Uri | undefined ;
36+
37+ const _documentSelector = combineDocumentSelectors (
38+ languageServerOptions . documentSelector ,
39+ RazorLanguage . documentSelector
40+ ) ;
41+
42+ export function isRelevantDocument ( document : vscode . TextDocument | undefined ) : document is vscode . TextDocument {
43+ if ( document === undefined ) {
44+ return false ;
45+ }
46+
47+ return vscode . languages . match ( _documentSelector , document ) > 0 ;
48+ }
3749
3850export class ProjectContextService {
3951 // This map tracks which project context is active for a given context key. New entries are
@@ -59,11 +71,6 @@ export class ProjectContextService {
5971 _vs_is_miscellaneous : false ,
6072 } ;
6173
62- private readonly _documentSelector = combineDocumentSelectors (
63- languageServerOptions . documentSelector ,
64- RazorLanguage . documentSelector
65- ) ;
66-
6774 constructor (
6875 private _languageServer : RoslynLanguageServer ,
6976 _languageClient : RoslynLanguageClient ,
@@ -105,7 +112,7 @@ export class ProjectContextService {
105112 contextList : VSProjectContextList ,
106113 context : VSProjectContext
107114 ) : Promise < void > {
108- if ( ! this . isRelevantDocument ( document ) ) {
115+ if ( ! isRelevantDocument ( document ) ) {
109116 return ;
110117 }
111118
@@ -127,7 +134,7 @@ export class ProjectContextService {
127134
128135 public async refresh ( ) {
129136 const textEditor = vscode . window . activeTextEditor ;
130- if ( ! this . isRelevantDocument ( textEditor ?. document ) ) {
137+ if ( ! isRelevantDocument ( textEditor ?. document ) ) {
131138 return ;
132139 }
133140
@@ -145,10 +152,6 @@ export class ProjectContextService {
145152 _verifyTimeout = undefined ;
146153 }
147154
148- if ( _documentUriToVerify ) {
149- _documentUriToVerify = undefined ;
150- }
151-
152155 if ( ! this . _languageServer . isRunning ( ) ) {
153156 this . _contextChangeEmitter . fire ( {
154157 document,
@@ -210,14 +213,6 @@ export class ProjectContextService {
210213 }
211214 }
212215
213- private isRelevantDocument ( document : vscode . TextDocument | undefined ) : boolean {
214- if ( document === undefined ) {
215- return false ;
216- }
217-
218- return vscode . languages . match ( this . _documentSelector , document ) > 0 ;
219- }
220-
221216 private updateCaches ( uriString : UriString , contextList : VSProjectContextList ) {
222217 const oldContextKey = this . _uriToContextKeyMap . get ( uriString ) ;
223218 const newContextKey = contextList . _vs_key ;
0 commit comments