@@ -804,9 +804,9 @@ export interface Client {
804
804
getShowConfigureIntelliSenseButton ( ) : boolean ;
805
805
setShowConfigureIntelliSenseButton ( show : boolean ) : void ;
806
806
addTrustedCompiler ( path : string ) : Promise < void > ;
807
- getIncludes ( maxDepth : number , token : vscode . CancellationToken ) : Promise < GetIncludesResult > ;
807
+ getIncludes ( maxDepth : number ) : Promise < GetIncludesResult > ;
808
808
getChatContext ( uri : vscode . Uri , token : vscode . CancellationToken ) : Promise < ChatContextResult > ;
809
- getProjectContext ( uri : vscode . Uri , token : vscode . CancellationToken ) : Promise < ProjectContextResult > ;
809
+ getProjectContext ( uri : vscode . Uri ) : Promise < ProjectContextResult > ;
810
810
}
811
811
812
812
export function createClient ( workspaceFolder ?: vscode . WorkspaceFolder ) : Client {
@@ -2228,25 +2228,31 @@ export class DefaultClient implements Client {
2228
2228
await this . languageClient . sendNotification ( DidOpenNotification , params ) ;
2229
2229
}
2230
2230
2231
- public async getIncludes ( maxDepth : number , token : vscode . CancellationToken ) : Promise < GetIncludesResult > {
2231
+ /**
2232
+ * Copilot completion-related requests (e.g. getIncludes and getProjectContext) will have their cancellation tokens cancelled
2233
+ * if the current request times out (showing the user completion results without context info),
2234
+ * but the results can still be used for future requests (due to caching) so it's better to return results instead of cancelling.
2235
+ * This is different behavior from the getChatContext, which does handle cancel requests, since the request blocks
2236
+ * the UI results and always re-requests (no caching).
2237
+ */
2238
+
2239
+ public async getIncludes ( maxDepth : number ) : Promise < GetIncludesResult > {
2232
2240
const params : GetIncludesParams = { maxDepth : maxDepth } ;
2233
2241
await this . ready ;
2234
- return DefaultClient . withLspCancellationHandling (
2235
- ( ) => this . languageClient . sendRequest ( IncludesRequest , params , token ) , token ) ;
2242
+ return this . languageClient . sendRequest ( IncludesRequest , params ) ;
2236
2243
}
2237
2244
2238
- public async getChatContext ( uri : vscode . Uri , token : vscode . CancellationToken ) : Promise < ChatContextResult > {
2245
+ public async getProjectContext ( uri : vscode . Uri ) : Promise < ProjectContextResult > {
2239
2246
const params : TextDocumentIdentifier = { uri : uri . toString ( ) } ;
2240
- await withCancellation ( this . ready , token ) ;
2241
- return DefaultClient . withLspCancellationHandling (
2242
- ( ) => this . languageClient . sendRequest ( CppContextRequest , params , token ) , token ) ;
2247
+ await this . ready ;
2248
+ return this . languageClient . sendRequest ( ProjectContextRequest , params ) ;
2243
2249
}
2244
2250
2245
- public async getProjectContext ( uri : vscode . Uri , token : vscode . CancellationToken ) : Promise < ProjectContextResult > {
2251
+ public async getChatContext ( uri : vscode . Uri , token : vscode . CancellationToken ) : Promise < ChatContextResult > {
2246
2252
const params : TextDocumentIdentifier = { uri : uri . toString ( ) } ;
2247
2253
await withCancellation ( this . ready , token ) ;
2248
2254
return DefaultClient . withLspCancellationHandling (
2249
- ( ) => this . languageClient . sendRequest ( ProjectContextRequest , params , token ) , token ) ;
2255
+ ( ) => this . languageClient . sendRequest ( CppContextRequest , params , token ) , token ) ;
2250
2256
}
2251
2257
2252
2258
/**
@@ -2340,7 +2346,6 @@ export class DefaultClient implements Client {
2340
2346
throw e ;
2341
2347
}
2342
2348
}
2343
-
2344
2349
if ( token . isCancellationRequested ) {
2345
2350
throw new vscode . CancellationError ( ) ;
2346
2351
}
@@ -4151,7 +4156,7 @@ class NullClient implements Client {
4151
4156
getShowConfigureIntelliSenseButton ( ) : boolean { return false ; }
4152
4157
setShowConfigureIntelliSenseButton ( show : boolean ) : void { }
4153
4158
addTrustedCompiler ( path : string ) : Promise < void > { return Promise . resolve ( ) ; }
4154
- getIncludes ( maxDepth : number , token : vscode . CancellationToken ) : Promise < GetIncludesResult > { return Promise . resolve ( { } as GetIncludesResult ) ; }
4159
+ getIncludes ( maxDepth : number ) : Promise < GetIncludesResult > { return Promise . resolve ( { } as GetIncludesResult ) ; }
4155
4160
getChatContext ( uri : vscode . Uri , token : vscode . CancellationToken ) : Promise < ChatContextResult > { return Promise . resolve ( { } as ChatContextResult ) ; }
4156
- getProjectContext ( uri : vscode . Uri , token : vscode . CancellationToken ) : Promise < ProjectContextResult > { return Promise . resolve ( { } as ProjectContextResult ) ; }
4161
+ getProjectContext ( uri : vscode . Uri ) : Promise < ProjectContextResult > { return Promise . resolve ( { } as ProjectContextResult ) ; }
4157
4162
}
0 commit comments