@@ -136,7 +136,7 @@ public final class OpenAIPromptToCodeService: PromptToCodeServiceType {
136136 } ( )
137137
138138 let annotations = isDetached
139- ? [ ]
139+ ? " "
140140 : extractAnnotations ( editorInformation: editor, source: source)
141141
142142 let firstMessage : String ? = {
@@ -148,17 +148,15 @@ public final class OpenAIPromptToCodeService: PromptToCodeServiceType {
148148 \( code)
149149 ```
150150
151- line annotations found:
152- \( annotations. map { " - \( $0) " } . joined ( separator: " \n " ) )
151+ \( annotations)
153152 """
154153 default :
155154 return """
156155 ```
157156 \( code)
158157 ```
159158
160- line annotations found:
161- \( annotations. map { " - \( $0) " } . joined ( separator: " \n " ) )
159+ \( annotations)
162160 """
163161 }
164162 } ( )
@@ -274,9 +272,9 @@ public final class OpenAIPromptToCodeService: PromptToCodeServiceType {
274272 func extractAnnotations(
275273 editorInformation: EditorInformation ,
276274 source: PromptToCodeSource
277- ) -> [ String ] {
278- guard let annotations = editorInformation. editorContent? . lineAnnotations else { return [ ] }
279- return annotations
275+ ) -> String {
276+ guard let annotations = editorInformation. editorContent? . lineAnnotations else { return " " }
277+ let all = annotations
280278 . lazy
281279 . filter { annotation in
282280 annotation. line >= source. range. start. line + 1
@@ -285,6 +283,11 @@ public final class OpenAIPromptToCodeService: PromptToCodeServiceType {
285283 let relativeLine = annotation. line - source. range. start. line
286284 return " line \( relativeLine) : \( annotation. type) \( annotation. message) "
287285 }
286+ guard !all. isEmpty else { return " " }
287+ return """
288+ line annotations found:
289+ \( annotations. map { " - \( $0) " } . joined ( separator: " \n " ) )
290+ """
288291 }
289292}
290293
0 commit comments