Skip to content

Commit 60e7592

Browse files
committed
Remove snippet reverse
1 parent 86477f0 commit 60e7592

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

Core/Sources/SuggestionWidget/FeatureReducers/PromptToCodePanel.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public struct PromptToCodePanel {
4040
public var snippetPanels: IdentifiedArrayOf<PromptToCodeSnippetPanel.State> {
4141
get {
4242
IdentifiedArrayOf(
43-
uniqueElements: promptToCodeState.snippets.reversed().map {
43+
uniqueElements: promptToCodeState.snippets.map {
4444
PromptToCodeSnippetPanel.State(snippet: $0)
4545
}
4646
)
4747
}
4848
set {
4949
promptToCodeState.snippets = IdentifiedArrayOf(
50-
uniqueElements: newValue.map(\.snippet).reversed()
50+
uniqueElements: newValue.map(\.snippet)
5151
)
5252
}
5353
}
@@ -67,7 +67,8 @@ public struct PromptToCodePanel {
6767
contextInputController = PromptToCodeCustomization
6868
.contextInputControllerFactory(promptToCodeState)
6969
focusedField = .textField
70-
contextInputController.instruction = instruction.map(NSAttributedString.init(string:)) ?? .init()
70+
contextInputController.instruction = instruction
71+
.map(NSAttributedString.init(string:)) ?? .init()
7172
}
7273
}
7374

@@ -118,7 +119,11 @@ public struct PromptToCodePanel {
118119
let copiedState = state
119120
let contextInputController = state.contextInputController
120121
state.promptToCodeState.isGenerating = true
121-
state.promptToCodeState.pushHistory(instruction: .init(attributedString: contextInputController.instruction))
122+
state.promptToCodeState
123+
.pushHistory(instruction: .init(
124+
attributedString: contextInputController
125+
.instruction
126+
))
122127
let snippets = state.promptToCodeState.snippets
123128

124129
return .run { send in
@@ -153,7 +158,7 @@ public struct PromptToCodePanel {
153158
do {
154159
for try await response in stream {
155160
try Task.checkCancellation()
156-
161+
157162
switch response {
158163
case let .code(code):
159164
await send(.snippetPanel(.element(
@@ -213,7 +218,8 @@ public struct PromptToCodePanel {
213218
state.promptToCodeState.isGenerating = false
214219

215220
if state.promptToCodeState.snippets.allSatisfy({ snippet in
216-
snippet.modifiedCode.isEmpty && snippet.description.isEmpty && snippet.error == nil
221+
snippet.modifiedCode.isEmpty && snippet.description.isEmpty && snippet
222+
.error == nil
217223
}) {
218224
// if both code and description are empty, we treat it as failed
219225
return .run { send in

0 commit comments

Comments
 (0)