@@ -49,17 +49,13 @@ export class ProjectContextService {
49
49
this . _source . cancel ( ) ;
50
50
this . _source = new vscode . CancellationTokenSource ( ) ;
51
51
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 ;
62
55
}
56
+
57
+ const context = contextList . _vs_projectContexts [ contextList . _vs_defaultIndex ] ;
58
+ this . _contextChangeEmitter . fire ( { uri, context } ) ;
63
59
}
64
60
65
61
private async getProjectContexts (
@@ -69,10 +65,18 @@ export class ProjectContextService {
69
65
const uriString = UriConverter . serialize ( uri ) ;
70
66
const textDocument = TextDocumentIdentifier . create ( uriString ) ;
71
67
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
+ }
77
81
}
78
82
}
0 commit comments