diff --git a/Extension/src/LanguageServer/client.ts b/Extension/src/LanguageServer/client.ts index d1f0cb8c90..47e5d28219 100644 --- a/Extension/src/LanguageServer/client.ts +++ b/Extension/src/LanguageServer/client.ts @@ -527,6 +527,7 @@ interface DidChangeActiveEditorParams { } interface GetIncludesParams { + fileUri: string; maxDepth: number; } @@ -827,7 +828,7 @@ export interface Client { setShowConfigureIntelliSenseButton(show: boolean): void; addTrustedCompiler(path: string): Promise<void>; getCopilotHoverProvider(): CopilotHoverProvider | undefined; - getIncludes(maxDepth: number): Promise<GetIncludesResult>; + getIncludes(uri: vscode.Uri, maxDepth: number): Promise<GetIncludesResult>; getChatContext(uri: vscode.Uri, token: vscode.CancellationToken): Promise<ChatContextResult>; getProjectContext(uri: vscode.Uri): Promise<ProjectContextResult>; filesEncodingChanged(filesEncodingChanged: FilesEncodingChanged): void; @@ -2291,8 +2292,8 @@ export class DefaultClient implements Client { * the UI results and always re-requests (no caching). */ - public async getIncludes(maxDepth: number): Promise<GetIncludesResult> { - const params: GetIncludesParams = { maxDepth: maxDepth }; + public async getIncludes(uri: vscode.Uri, maxDepth: number): Promise<GetIncludesResult> { + const params: GetIncludesParams = { fileUri: uri.toString(), maxDepth }; await this.ready; return this.languageClient.sendRequest(IncludesRequest, params); } @@ -4235,7 +4236,7 @@ class NullClient implements Client { setShowConfigureIntelliSenseButton(show: boolean): void { } addTrustedCompiler(path: string): Promise<void> { return Promise.resolve(); } getCopilotHoverProvider(): CopilotHoverProvider | undefined { return undefined; } - getIncludes(maxDepth: number): Promise<GetIncludesResult> { return Promise.resolve({} as GetIncludesResult); } + getIncludes(uri: vscode.Uri, maxDepth: number): Promise<GetIncludesResult> { return Promise.resolve({} as GetIncludesResult); } getChatContext(uri: vscode.Uri, token: vscode.CancellationToken): Promise<ChatContextResult> { return Promise.resolve({} as ChatContextResult); } getProjectContext(uri: vscode.Uri): Promise<ProjectContextResult> { return Promise.resolve({} as ProjectContextResult); } filesEncodingChanged(filesEncodingChanged: FilesEncodingChanged): void { } diff --git a/Extension/src/LanguageServer/copilotProviders.ts b/Extension/src/LanguageServer/copilotProviders.ts index a78fdfa5b6..ce232865fa 100644 --- a/Extension/src/LanguageServer/copilotProviders.ts +++ b/Extension/src/LanguageServer/copilotProviders.ts @@ -10,7 +10,7 @@ import * as util from '../common'; import * as logger from '../logger'; import * as telemetry from '../telemetry'; import { GetIncludesResult } from './client'; -import { getActiveClient } from './extension'; +import { getClients } from './extension'; import { getCompilerArgumentFilterMap, getProjectContext } from './lmTool'; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); @@ -46,7 +46,7 @@ export async function registerRelatedFilesProvider(): Promise<void> { const telemetryProperties: Record<string, string> = {}; const telemetryMetrics: Record<string, number> = {}; try { - const getIncludesHandler = async () => (await getIncludes(1))?.includedFiles.map(file => vscode.Uri.file(file)) ?? []; + const getIncludesHandler = async () => (await getIncludes(uri, 1))?.includedFiles.map(file => vscode.Uri.file(file)) ?? []; const getTraitsHandler = async () => { const projectContext = await getProjectContext(uri, context); @@ -157,10 +157,10 @@ export async function registerRelatedFilesProvider(): Promise<void> { } } -async function getIncludes(maxDepth: number): Promise<GetIncludesResult> { - const activeClient = getActiveClient(); - const includes = await activeClient.getIncludes(maxDepth); - const wksFolder = activeClient.RootUri?.toString(); +async function getIncludes(uri: vscode.Uri, maxDepth: number): Promise<GetIncludesResult> { + const client = getClients().getClientFor(uri); + const includes = await client.getIncludes(uri, maxDepth); + const wksFolder = client.RootUri?.toString(); if (!wksFolder) { return includes;