Skip to content

Commit 870dc52

Browse files
committed
Fix GitHubCopilotService parsing response
1 parent 683d0b6 commit 870dc52

2 files changed

Lines changed: 23 additions & 20 deletions

File tree

Tool/Sources/GitHubCopilotService/GitHubCopilotRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ enum GitHubCopilotRequest {
186186

187187
struct GetCompletionsCycling: GitHubCopilotRequestType {
188188
struct Response: Codable {
189-
var completions: [CodeSuggestion]
189+
var completions: [GitHubCopilotCodeSuggestion]
190190
}
191191

192192
var doc: GitHubCopilotDoc

Tool/Sources/GitHubCopilotService/GitHubCopilotService.swift

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,12 @@ public class GitHubCopilotBaseService {
8181
"\"\(agentJSURL.path)\"",
8282
"--stdio",
8383
].joined(separator: " ")
84-
executionParams = {
85-
Process.ExecutionParameters(
86-
path: "/bin/bash",
87-
arguments: ["-i", "-l", "-c", command],
88-
environment: [:],
89-
currentDirectoryURL: urls.supportURL
90-
)
91-
}()
84+
executionParams = Process.ExecutionParameters(
85+
path: "/bin/bash",
86+
arguments: ["-i", "-l", "-c", command],
87+
environment: [:],
88+
currentDirectoryURL: urls.supportURL
89+
)
9290
case .shell:
9391
let shell = ProcessInfo.processInfo.shellExecutablePath
9492
let nodePath = UserDefaults.shared.value(for: \.nodePath)
@@ -97,16 +95,15 @@ public class GitHubCopilotBaseService {
9795
"\"\(agentJSURL.path)\"",
9896
"--stdio",
9997
].joined(separator: " ")
100-
executionParams = {
101-
Process.ExecutionParameters(
102-
path: shell,
103-
arguments: ["-i", "-l", "-c", command],
104-
environment: [:],
105-
currentDirectoryURL: urls.supportURL
106-
)
107-
}()
98+
executionParams = Process.ExecutionParameters(
99+
path: shell,
100+
arguments: ["-i", "-l", "-c", command],
101+
environment: [:],
102+
currentDirectoryURL: urls.supportURL
103+
)
108104
case .env:
109-
let userEnvPath = "/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
105+
let userEnvPath =
106+
"/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
110107
executionParams = {
111108
let nodePath = UserDefaults.shared.value(for: \.nodePath)
112109
return Process.ExecutionParameters(
@@ -313,16 +310,22 @@ public final class GitHubCopilotSuggestionService: GitHubCopilotBaseService,
313310
return true
314311
}
315312
.map {
313+
var suggestion = CodeSuggestion(
314+
id: $0.uuid,
315+
text: $0.text,
316+
position: $0.position,
317+
range: $0.range
318+
)
316319
if ignoreTrailingNewLinesAndSpaces {
317-
var updated = $0
320+
var updated = suggestion
318321
var text = updated.text[...]
319322
while let last = text.last, last.isNewline || last.isWhitespace {
320323
text = text.dropLast(1)
321324
}
322325
updated.text = String(text)
323326
return updated
324327
}
325-
return $0
328+
return suggestion
326329
}
327330
try Task.checkCancellation()
328331
return completions

0 commit comments

Comments
 (0)