@@ -804,9 +804,9 @@ export interface Client {
804804 getShowConfigureIntelliSenseButton ( ) : boolean ;
805805 setShowConfigureIntelliSenseButton ( show : boolean ) : void ;
806806 addTrustedCompiler ( path : string ) : Promise < void > ;
807- getIncludes ( maxDepth : number , token : vscode . CancellationToken ) : Promise < GetIncludesResult > ;
807+ getIncludes ( maxDepth : number ) : Promise < GetIncludesResult > ;
808808 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 > ;
810810}
811811
812812export function createClient ( workspaceFolder ?: vscode . WorkspaceFolder ) : Client {
@@ -2228,25 +2228,31 @@ export class DefaultClient implements Client {
22282228 await this . languageClient . sendNotification ( DidOpenNotification , params ) ;
22292229 }
22302230
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 > {
22322240 const params : GetIncludesParams = { maxDepth : maxDepth } ;
22332241 await this . ready ;
2234- return DefaultClient . withLspCancellationHandling (
2235- ( ) => this . languageClient . sendRequest ( IncludesRequest , params , token ) , token ) ;
2242+ return this . languageClient . sendRequest ( IncludesRequest , params ) ;
22362243 }
22372244
2238- public async getChatContext ( uri : vscode . Uri , token : vscode . CancellationToken ) : Promise < ChatContextResult > {
2245+ public async getProjectContext ( uri : vscode . Uri ) : Promise < ProjectContextResult > {
22392246 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 ) ;
22432249 }
22442250
2245- public async getProjectContext ( uri : vscode . Uri , token : vscode . CancellationToken ) : Promise < ProjectContextResult > {
2251+ public async getChatContext ( uri : vscode . Uri , token : vscode . CancellationToken ) : Promise < ChatContextResult > {
22462252 const params : TextDocumentIdentifier = { uri : uri . toString ( ) } ;
22472253 await withCancellation ( this . ready , token ) ;
22482254 return DefaultClient . withLspCancellationHandling (
2249- ( ) => this . languageClient . sendRequest ( ProjectContextRequest , params , token ) , token ) ;
2255+ ( ) => this . languageClient . sendRequest ( CppContextRequest , params , token ) , token ) ;
22502256 }
22512257
22522258 /**
@@ -2340,7 +2346,6 @@ export class DefaultClient implements Client {
23402346 throw e ;
23412347 }
23422348 }
2343-
23442349 if ( token . isCancellationRequested ) {
23452350 throw new vscode . CancellationError ( ) ;
23462351 }
@@ -4151,7 +4156,7 @@ class NullClient implements Client {
41514156 getShowConfigureIntelliSenseButton ( ) : boolean { return false ; }
41524157 setShowConfigureIntelliSenseButton ( show : boolean ) : void { }
41534158 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 ) ; }
41554160 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 ) ; }
41574162}
0 commit comments