@@ -20,7 +20,7 @@ import * as util from '../common';
2020import { getCrashCallStacksChannel } from '../logger' ;
2121import { PlatformInformation } from '../platform' ;
2222import * as telemetry from '../telemetry' ;
23- import { Client , DefaultClient , DoxygenCodeActionCommandArguments , openFileVersions } from './client' ;
23+ import { Client , DefaultClient , DoxygenCodeActionCommandArguments , GetIncludesResult , openFileVersions } from './client' ;
2424import { ClientCollection } from './clientCollection' ;
2525import { CodeActionDiagnosticInfo , CodeAnalysisDiagnosticIdentifiersAndUri , codeAnalysisAllFixes , codeAnalysisCodeToFixes , codeAnalysisFileToCodeActions } from './codeAnalysis' ;
2626import { CppBuildTaskProvider } from './cppBuildTaskProvider' ;
@@ -282,7 +282,7 @@ export async function activate(): Promise<void> {
282282 api . registerRelatedFilesProvider (
283283 { extensionId : util . extensionContext . extension . id , languageId } ,
284284 async ( _uri : vscode . Uri , _context : { flags : Record < string , unknown > } , token : vscode . CancellationToken ) =>
285- ( { entries : ( await clients . ActiveClient . getIncludes ( 1 , token ) ) ?. includedFiles . map ( file => vscode . Uri . file ( file ) ) ?? [ ] } )
285+ ( { entries : ( await getIncludesWithCancellation ( 1 , token ) ) ?. includedFiles . map ( file => vscode . Uri . file ( file ) ) ?? [ ] } )
286286 ) ;
287287 }
288288 } catch {
@@ -1413,13 +1413,28 @@ export async function preReleaseCheck(): Promise<void> {
14131413 }
14141414}
14151415
1416- export async function getIncludes ( maxDepth : number ) : Promise < any > {
1417- const tokenSource = new vscode . CancellationTokenSource ( ) ;
1418- const includes = await clients . ActiveClient . getIncludes ( maxDepth , tokenSource . token ) ;
1419- tokenSource . dispose ( ) ;
1416+ export async function getIncludesWithCancellation ( maxDepth : number , token : vscode . CancellationToken ) : Promise < GetIncludesResult > {
1417+ const includes = await clients . ActiveClient . getIncludes ( maxDepth , token ) ;
1418+ const wksFolder = clients . ActiveClient . RootUri ?. toString ( ) ;
1419+
1420+ if ( ! wksFolder ) {
1421+ return includes ;
1422+ }
1423+
1424+ includes . includedFiles = includes . includedFiles . filter ( header => vscode . Uri . file ( header ) . toString ( ) . startsWith ( wksFolder ) ) ;
14201425 return includes ;
14211426}
14221427
1428+ async function getIncludes ( maxDepth : number ) : Promise < GetIncludesResult > {
1429+ const tokenSource = new vscode . CancellationTokenSource ( ) ;
1430+ try {
1431+ const includes = await getIncludesWithCancellation ( maxDepth , tokenSource . token ) ;
1432+ return includes ;
1433+ } finally {
1434+ tokenSource . dispose ( ) ;
1435+ }
1436+ }
1437+
14231438async function getCopilotApi ( ) : Promise < CopilotApi | undefined > {
14241439 const copilotExtension = vscode . extensions . getExtension < CopilotApi > ( 'github.copilot' ) ;
14251440 if ( ! copilotExtension ) {
0 commit comments