Skip to content

Commit e3e8bca

Browse files
committed
Make chat with selection and prompt to code return immediately
1 parent 42d81bf commit e3e8bca

File tree

2 files changed

+6
-26
lines changed

2 files changed

+6
-26
lines changed

EditorExtension/ChatWithSelection.swift

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,10 @@ class ChatWithSelectionCommand: NSObject, XCSourceEditorCommand, CommandType {
1010
with invocation: XCSourceEditorCommandInvocation,
1111
completionHandler: @escaping (Error?) -> Void
1212
) {
13+
completionHandler(nil)
1314
Task {
14-
do {
15-
let service = try getService()
16-
if let content = try await service.chatWithSelection(
17-
editorContent: .init(invocation)
18-
) {
19-
invocation.accept(content)
20-
}
21-
completionHandler(nil)
22-
} catch is CancellationError {
23-
completionHandler(nil)
24-
} catch {
25-
completionHandler(error)
26-
}
15+
let service = try getService()
16+
_ = try await service.chatWithSelection(editorContent: .init(invocation))
2717
}
2818
}
2919
}

EditorExtension/PromptToCodeCommand.swift

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,10 @@ class PromptToCodeCommand: NSObject, XCSourceEditorCommand, CommandType {
1010
with invocation: XCSourceEditorCommandInvocation,
1111
completionHandler: @escaping (Error?) -> Void
1212
) {
13+
completionHandler(nil)
1314
Task {
14-
do {
15-
let service = try getService()
16-
if let content = try await service.promptToCode(
17-
editorContent: .init(invocation)
18-
) {
19-
invocation.accept(content)
20-
}
21-
completionHandler(nil)
22-
} catch is CancellationError {
23-
completionHandler(nil)
24-
} catch {
25-
completionHandler(error)
26-
}
15+
let service = try getService()
16+
_ = try await service.promptToCode(editorContent: .init(invocation))
2717
}
2818
}
2919
}

0 commit comments

Comments
 (0)