@@ -56,7 +56,7 @@ public final class SuggestionWidgetController {
5656 private var suggestionForFiles : [ URL : Suggestion ] = [ : ]
5757
5858 enum Suggestion {
59- case code( [ String ] , startLineIndex: Int )
59+ case code( [ String ] , startLineIndex: Int , currentSuggestionIndex : Int , suggestionCount : Int )
6060 }
6161
6262 public nonisolated init ( ) {
@@ -83,14 +83,24 @@ public final class SuggestionWidgetController {
8383 }
8484 }
8585
86- public func suggestCode( _ code: String , startLineIndex: Int , fileURL: URL ) {
86+ public func suggestCode(
87+ _ code: String ,
88+ startLineIndex: Int ,
89+ fileURL: URL ,
90+ currentSuggestionIndex: Int ,
91+ suggestionCount: Int
92+ ) {
8793 withAnimation ( . easeInOut( duration: 0.2 ) ) {
8894 suggestionPanelViewModel. suggestion = code. split ( separator: " \n " ) . map ( String . init)
8995 suggestionPanelViewModel. startLineIndex = startLineIndex
9096 suggestionPanelViewModel. isPanelDisplayed = true
97+ suggestionPanelViewModel. currentSuggestionIndex = currentSuggestionIndex
98+ suggestionPanelViewModel. suggestionCount = suggestionCount
9199 suggestionForFiles [ fileURL] = . code(
92100 suggestionPanelViewModel. suggestion,
93- startLineIndex: startLineIndex
101+ startLineIndex: startLineIndex,
102+ currentSuggestionIndex: currentSuggestionIndex,
103+ suggestionCount: suggestionCount
94104 )
95105 widgetViewModel. isProcessing = false
96106 }
@@ -101,6 +111,8 @@ public final class SuggestionWidgetController {
101111 suggestionForFiles [ fileURL] = nil
102112 suggestionPanelViewModel. suggestion = [ ]
103113 suggestionPanelViewModel. startLineIndex = 0
114+ suggestionPanelViewModel. currentSuggestionIndex = 0
115+ suggestionPanelViewModel. suggestionCount = 0
104116 suggestionPanelViewModel. isPanelDisplayed = false
105117 widgetViewModel. isProcessing = false
106118 }
@@ -136,9 +148,11 @@ public final class SuggestionWidgetController {
136148 continue
137149 }
138150 switch suggestion {
139- case let . code( code, startLineIndex) :
151+ case let . code( code, startLineIndex, currentSuggestionIndex , suggestionCount ) :
140152 suggestionPanelViewModel. suggestion = code
141153 suggestionPanelViewModel. startLineIndex = startLineIndex
154+ suggestionPanelViewModel. currentSuggestionIndex = currentSuggestionIndex
155+ suggestionPanelViewModel. suggestionCount = suggestionCount
142156 }
143157 }
144158 }
0 commit comments