Skip to content

Commit a6830bf

Browse files
committed
Merge branch 'feature/github-copilot-1.9.1' into develop
2 parents d4dca03 + 876c6be commit a6830bf

File tree

5 files changed

+49
-10
lines changed

5 files changed

+49
-10
lines changed

Core/Sources/GitHubCopilotService/CopilotLocalProcessServer.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ extension CustomJSONRPCLanguageServer {
222222
}
223223
block(nil)
224224
return true
225+
case "featureFlagsNotification":
226+
if UserDefaults.shared.value(for: \.gitHubCopilotVerboseLog) {
227+
Logger.gitHubCopilot
228+
.info("\(anyNotification.method): \(anyNotification.params.debugDescription)")
229+
}
230+
block(nil)
231+
return true
225232
default:
226233
return false
227234
}

Core/Sources/GitHubCopilotService/GitHubCopilotInstallationManager.swift

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ public struct GitHubCopilotInstallationManager {
55
private static var isInstalling = false
66

77
static var downloadURL: URL {
8-
let commitHash = "1358e8e45ecedc53daf971924a0541ddf6224faf"
8+
let commitHash = "a4a6d6b3f9e284e7f5c849619e06cd228cad8abd"
99
let link = "https://github.com/github/copilot.vim/archive/\(commitHash).zip"
1010
return URL(string: link)!
1111
}
1212

13-
static let latestSupportedVersion = "1.8.4"
13+
static let latestSupportedVersion = "1.9.1"
1414

1515
public init() {}
1616

@@ -113,7 +113,7 @@ public struct GitHubCopilotInstallationManager {
113113
includingPropertiesForKeys: nil,
114114
options: []
115115
)
116-
116+
117117
defer {
118118
for url in contentURLs {
119119
try? FileManager.default.removeItem(at: url)
@@ -127,8 +127,18 @@ public struct GitHubCopilotInstallationManager {
127127
return
128128
}
129129

130-
let lspURL = gitFolderURL.appendingPathComponent("copilot")
131-
let installationURL = urls.executableURL.appendingPathComponent("copilot")
130+
let lspURL = gitFolderURL.appendingPathComponent("dist")
131+
let copilotURL = urls.executableURL.appendingPathComponent("copilot")
132+
133+
if !FileManager.default.fileExists(atPath: copilotURL.path) {
134+
try FileManager.default.createDirectory(
135+
at: copilotURL,
136+
withIntermediateDirectories: true,
137+
attributes: nil
138+
)
139+
}
140+
141+
let installationURL = copilotURL.appendingPathComponent("dist")
132142
try FileManager.default.copyItem(at: lspURL, to: installationURL)
133143

134144
// update permission 755

Core/Sources/GitHubCopilotService/GitHubCopilotService.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,11 @@ public class GitHubCopilotBaseService {
165165

166166
self.server = server
167167
localProcessServer = localServer
168-
168+
169169
Task {
170170
try await server.sendRequest(GitHubCopilotRequest.SetEditorInfo())
171171
}
172172
}
173-
174-
175173

176174
public static func createFoldersIfNeeded() throws -> (
177175
applicationSupportURL: URL,
@@ -314,6 +312,18 @@ public final class GitHubCopilotSuggestionService: GitHubCopilotBaseService,
314312
}
315313
return true
316314
}
315+
.map {
316+
if UserDefaults.shared.value(for: \.gitHubCopilotIgnoreTrailingNewLines) {
317+
var updated = $0
318+
var text = updated.text[...]
319+
while text.hasSuffix("\n") {
320+
text = text.dropLast(1)
321+
}
322+
updated.text = String(text)
323+
return updated
324+
}
325+
return $0
326+
}
317327
try Task.checkCancellation()
318328
return completions
319329
}

Core/Sources/HostApp/AccountSettings/CopilotView.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ struct CopilotView: View {
1818
@AppStorage(\.gitHubCopilotProxyUsername) var gitHubCopilotProxyUsername
1919
@AppStorage(\.gitHubCopilotProxyPassword) var gitHubCopilotProxyPassword
2020
@AppStorage(\.gitHubCopilotUseStrictSSL) var gitHubCopilotUseStrictSSL
21-
21+
@AppStorage(\.gitHubCopilotIgnoreTrailingNewLines)
22+
var gitHubCopilotIgnoreTrailingNewLines
2223
init() {}
2324
}
2425

@@ -229,13 +230,20 @@ struct CopilotView: View {
229230
Divider()
230231

231232
Form {
233+
Toggle(
234+
"Ignore Trailing New Lines",
235+
isOn: $settings.gitHubCopilotIgnoreTrailingNewLines
236+
)
232237
Toggle("Verbose Log", isOn: $settings.gitHubCopilotVerboseLog)
233238
}
234239

235240
Divider()
236241

237242
Form {
238-
TextField(text: $settings.gitHubCopilotProxyHost, prompt: Text("xxx.xxx.xxx.xxx, leave it blank to disable proxy.")) {
243+
TextField(
244+
text: $settings.gitHubCopilotProxyHost,
245+
prompt: Text("xxx.xxx.xxx.xxx, leave it blank to disable proxy.")
246+
) {
239247
Text("Proxy Host")
240248
}
241249
TextField(text: $settings.gitHubCopilotProxyPort, prompt: Text("80")) {

Tool/Sources/Preferences/Keys.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ public extension UserDefaultPreferenceKeys {
160160
var runNodeWith: PreferenceKey<NodeRunner> {
161161
.init(defaultValue: .env, key: "RunNodeWith")
162162
}
163+
164+
var gitHubCopilotIgnoreTrailingNewLines: PreferenceKey<Bool> {
165+
.init(defaultValue: false, key: "GitHubCopilotIgnoreTrailingNewLines")
166+
}
163167
}
164168

165169
// MARK: - Codeium Settings

0 commit comments

Comments
 (0)