From 43ba6fdd8dca34aabc6c7e71e579856cb863a84f Mon Sep 17 00:00:00 2001 From: Shx Guo Date: Mon, 23 Dec 2024 02:17:02 +0800 Subject: [PATCH] Support setting language to GitHub Copilot chat --- .../LanguageServer/GitHubCopilotRequest.swift | 1 + .../Services/GitHubCopilotChatService.swift | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotRequest.swift b/Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotRequest.swift index 1cbbf546..87219683 100644 --- a/Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotRequest.swift +++ b/Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotRequest.swift @@ -376,6 +376,7 @@ enum GitHubCopilotRequest { var source: GitHubCopilotChatSource? // inline or panel var workspaceFolder: String? + var userLanguage: String? } let requestBody: RequestBody diff --git a/Tool/Sources/GitHubCopilotService/Services/GitHubCopilotChatService.swift b/Tool/Sources/GitHubCopilotService/Services/GitHubCopilotChatService.swift index 459b259a..1534b961 100644 --- a/Tool/Sources/GitHubCopilotService/Services/GitHubCopilotChatService.swift +++ b/Tool/Sources/GitHubCopilotService/Services/GitHubCopilotChatService.swift @@ -43,7 +43,14 @@ public final class GitHubCopilotChatService: BuiltinExtensionChatServiceType { capabilities: .init(allSkills: false, skills: []), doc: doc, source: .panel, - workspaceFolder: workspace.projectURL.path + workspaceFolder: workspace.projectURL.path, + userLanguage: { + let language = UserDefaults.shared.value(for: \.chatGPTLanguage) + if language.isEmpty { + return "Auto Detected" + } + return language + }() )) let stream = AsyncThrowingStream { continuation in