@@ -61,7 +61,13 @@ public final class PromptToCodeService: ObservableObject {
6161 description = fragment. description
6262 }
6363 }
64+ } catch is CancellationError {
65+ return
6466 } catch {
67+ if ( error as NSError ) . code == NSURLErrorCancelled {
68+ return
69+ }
70+
6571 if let oldCode {
6672 code = oldCode
6773 }
@@ -81,7 +87,7 @@ public final class PromptToCodeService: ObservableObject {
8187 description = oldDescription
8288 }
8389 self . oldCode = nil
84- self . oldDescription = nil
90+ oldDescription = nil
8591 }
8692
8793 public func generateCompletion( ) -> CopilotCompletion {
@@ -130,7 +136,7 @@ final class OpenAIPromptToCodeAPI: PromptToCodeAPI {
130136 ) async throws -> AsyncThrowingStream < ( code: String , description: String ) , Error > {
131137 let userPreferredLanguage = UserDefaults . shared. value ( for: \. chatGPTLanguage)
132138 let textLanguage = userPreferredLanguage. isEmpty ? " " : " in \( userPreferredLanguage) "
133-
139+
134140 let prompt = {
135141 let indentRule = usesTabsForIndentation ? " \( indentSize) tabs " : " \( indentSize) spaces "
136142 if code. isEmpty {
@@ -141,7 +147,9 @@ final class OpenAIPromptToCodeAPI: PromptToCodeAPI {
141147 indentRule
142148 ) .
143149
144- Please reply to me start with the code block, followed by a short description in 1-3 sentences about what you did \( textLanguage) .
150+ Please reply to me start with the code block, followed by a short description in 1-3 sentences about what you did \(
151+ textLanguage
152+ ) .
145153 """
146154 } else {
147155 return """
@@ -151,7 +159,9 @@ final class OpenAIPromptToCodeAPI: PromptToCodeAPI {
151159 indentRule
152160 ) .
153161
154- Please reply to me start with the code block followed by a short description about what you did in 1-3 sentences \( textLanguage) .
162+ Please reply to me start with the code block followed by a short description about what you did in 1-3 sentences \(
163+ textLanguage
164+ ) .
155165
156166 ```
157167 \( code)
0 commit comments