Skip to content

Commit a00642a

Browse files
committed
Bump GitHub Copilot language server
1 parent f7863d9 commit a00642a

File tree

3 files changed

+39
-33
lines changed

3 files changed

+39
-33
lines changed

Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotInstallationManager.swift

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,15 @@ public struct GitHubCopilotInstallationManager {
66
public private(set) static var isInstalling = false
77

88
static var downloadURL: URL {
9-
let commitHash = "a9228e015528c9307890c48083c925eb98a64a79"
9+
let commitHash = "18f485d892b56b311fd752039d6977333ebc2a0f"
1010
let link = "https://github.com/github/copilot.vim/archive/\(commitHash).zip"
1111
return URL(string: link)!
1212
}
1313

14-
/// trying to update to a newer version but completions stop working for some reasons.
15-
/// As a reference, the changes starts since 1.45.0 and GitHub's extension updates the
16-
/// language server since this commit:
17-
/// https://github.com/github/CopilotForXcode/commit/b2189de633417a49d6d2022aad5ff0748ebed2ac#diff-678798cf677bcd1ce276809cfccd33da9ff594b1b0c557180210a4ed2bd27ffa
18-
/// It jumps directly to 1.48.0 from a much lower version.
19-
static let latestSupportedVersion = "1.44.0"
14+
/// The GitHub's version has quite a lot of changes about `watchedFiles` since the following
15+
/// commit.
16+
/// https://github.com/github/CopilotForXcode/commit/a50045aa3ab3b7d532cadf40c4c10bed32f81169#diff-678798cf677bcd1ce276809cfccd33da9ff594b1b0c557180210a4ed2bd27ffa
17+
static let latestSupportedVersion = "1.48.0"
2018
static let minimumSupportedVersion = "1.32.0"
2119

2220
public init() {}
@@ -47,11 +45,23 @@ public struct GitHubCopilotInstallationManager {
4745
case .orderedAscending:
4846
switch version.compare(Self.minimumSupportedVersion) {
4947
case .orderedAscending:
50-
return .outdated(current: version, latest: Self.latestSupportedVersion, mandatory: true)
48+
return .outdated(
49+
current: version,
50+
latest: Self.latestSupportedVersion,
51+
mandatory: true
52+
)
5153
case .orderedSame:
52-
return .outdated(current: version, latest: Self.latestSupportedVersion, mandatory: false)
54+
return .outdated(
55+
current: version,
56+
latest: Self.latestSupportedVersion,
57+
mandatory: false
58+
)
5359
case .orderedDescending:
54-
return .outdated(current: version, latest: Self.latestSupportedVersion, mandatory: false)
60+
return .outdated(
61+
current: version,
62+
latest: Self.latestSupportedVersion,
63+
mandatory: false
64+
)
5565
}
5666
case .orderedSame:
5767
return .installed(version)

Tool/Sources/GitHubCopilotService/LanguageServer/GitHubCopilotService.swift

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ public class GitHubCopilotBaseService {
134134
let urls = try GitHubCopilotBaseService.createFoldersIfNeeded()
135135
let executionParams: Process.ExecutionParameters
136136
let runner = UserDefaults.shared.value(for: \.runNodeWith)
137-
let watchedFiles = JSONValue(
138-
booleanLiteral: projectRootURL.path == "/" ? false : true
139-
)
137+
// let watchedFiles = JSONValue(
138+
// booleanLiteral: projectRootURL.path == "/" ? false : true
139+
// )
140140

141141
guard let agentJSURL = { () -> URL? in
142142
let languageServerDotJS = urls.executableURL
@@ -241,17 +241,7 @@ public class GitHubCopilotBaseService {
241241

242242
server.initializeParamsProvider = {
243243
let capabilities = ClientCapabilities(
244-
workspace: .init(
245-
applyEdit: false,
246-
workspaceEdit: nil,
247-
didChangeConfiguration: nil,
248-
didChangeWatchedFiles: nil,
249-
symbol: nil,
250-
executeCommand: nil,
251-
workspaceFolders: true,
252-
configuration: nil,
253-
semanticTokens: nil
254-
),
244+
workspace: nil,
255245
textDocument: nil,
256246
window: nil,
257247
general: nil,
@@ -283,15 +273,15 @@ public class GitHubCopilotBaseService {
283273
"version": .string(Bundle.main
284274
.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""),
285275
]),
286-
"copilotCapabilities": [
287-
/// The editor has support for watching files over LSP
288-
"watchedFiles": watchedFiles,
289-
],
276+
// "copilotCapabilities": [
277+
// /// The editor has support for watching files over LSP
278+
// "watchedFiles": watchedFiles,
279+
// ],
290280
],
291281
capabilities: capabilities,
292282
trace: .off,
293283
workspaceFolders: [WorkspaceFolder(
294-
uri: projectRootURL.path,
284+
uri: projectRootURL.absoluteString,
295285
name: projectRootURL.lastPathComponent
296286
)]
297287
)
@@ -474,7 +464,7 @@ public final class GitHubCopilotService: GitHubCopilotBaseService,
474464
do {
475465
let completions = try await server
476466
.sendRequest(GitHubCopilotRequest.InlineCompletion(doc: .init(
477-
textDocument: .init(uri: fileURL.path, version: 1),
467+
textDocument: .init(uri: fileURL.absoluteString, version: 1),
478468
position: cursorPosition,
479469
formattingOptions: .init(
480470
tabSize: tabSize,

Tool/Sources/GitHubCopilotService/Services/GitHubCopilotChatService.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ public final class GitHubCopilotChatService: BuiltinExtensionChatServiceType {
3131
tabSize: 1,
3232
indentSize: 4,
3333
insertSpaces: true,
34-
path: editorContent?.documentURL.path ?? "",
35-
uri: editorContent?.documentURL.path ?? "",
34+
path: editorContent?.documentURL.absoluteString ?? "",
35+
uri: editorContent?.documentURL.absoluteString ?? "",
3636
relativePath: editorContent?.relativePath ?? "",
3737
languageId: editorContent?.language ?? .plaintext,
3838
position: editorContent?.editorContent?.cursorPosition ?? .zero
@@ -43,7 +43,7 @@ public final class GitHubCopilotChatService: BuiltinExtensionChatServiceType {
4343
capabilities: .init(skills: [], allSkills: false),
4444
textDocument: doc,
4545
source: .panel,
46-
workspaceFolder: workspace.projectURL.path,
46+
workspaceFolder: workspace.projectURL.absoluteString,
4747
model: {
4848
let selectedModel = UserDefaults.shared.value(for: \.gitHubCopilotModelId)
4949
if selectedModel.isEmpty {
@@ -97,6 +97,12 @@ public final class GitHubCopilotChatService: BuiltinExtensionChatServiceType {
9797
"\(error). Please try enabling pretend IDE to be VSCode and click refresh configuration."
9898
)
9999
)
100+
} else if error.contains("No model configuration found") {
101+
continuation.finish(
102+
throwing: GitHubCopilotError.chatEndsWithError(
103+
"\(error). Please try enabling pretend IDE to be VSCode and click refresh configuration."
104+
)
105+
)
100106
} else {
101107
continuation.finish(
102108
throwing: GitHubCopilotError.chatEndsWithError(error)

0 commit comments

Comments
 (0)