@@ -49,17 +49,13 @@ export class ProjectContextService {
4949 this . _source . cancel ( ) ;
5050 this . _source = new vscode . CancellationTokenSource ( ) ;
5151
52- try {
53- const contextList = await this . getProjectContexts ( uri , this . _source . token ) ;
54- if ( ! contextList ) {
55- return ;
56- }
57-
58- const context = contextList . _vs_projectContexts [ contextList . _vs_defaultIndex ] ;
59- this . _contextChangeEmitter . fire ( { uri, context } ) ;
60- } catch {
61- // This request was cancelled
52+ const contextList = await this . getProjectContexts ( uri , this . _source . token ) ;
53+ if ( ! contextList ) {
54+ return ;
6255 }
56+
57+ const context = contextList . _vs_projectContexts [ contextList . _vs_defaultIndex ] ;
58+ this . _contextChangeEmitter . fire ( { uri, context } ) ;
6359 }
6460
6561 private async getProjectContexts (
@@ -69,10 +65,18 @@ export class ProjectContextService {
6965 const uriString = UriConverter . serialize ( uri ) ;
7066 const textDocument = TextDocumentIdentifier . create ( uriString ) ;
7167
72- return this . _languageServer . sendRequest (
73- VSGetProjectContextsRequest . type ,
74- { _vs_textDocument : textDocument } ,
75- token
76- ) ;
68+ try {
69+ return this . _languageServer . sendRequest (
70+ VSGetProjectContextsRequest . type ,
71+ { _vs_textDocument : textDocument } ,
72+ token
73+ ) ;
74+ } catch ( error ) {
75+ if ( error instanceof vscode . CancellationError ) {
76+ return undefined ;
77+ }
78+
79+ throw error ;
80+ }
7781 }
7882}
0 commit comments