Skip to content

Commit da004a3

Browse files
committed
Use the new text editor in prompt to code
1 parent 7ac2fb3 commit da004a3

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

Core/Sources/SuggestionWidget/SuggestionPanelContent/PromptToCodePanel.swift

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,21 +191,26 @@ struct PromptToCodePanelToolbar: View {
191191
.disabled(provider.isResponding || !provider.canRevert)
192192

193193
HStack(spacing: 0) {
194-
Group {
195-
if #available(macOS 13.0, *) {
196-
TextField("Requriement", text: $provider.requirement, axis: .vertical)
197-
} else {
198-
TextEditor(text: $provider.requirement)
199-
.frame(height: 42, alignment: .leading)
200-
.font(.body)
201-
.background(Color.clear)
202-
}
194+
ZStack(alignment: .center) {
195+
// a hack to support dynamic height of TextEditor
196+
Text(provider.requirement.isEmpty ? "Hi" : provider.requirement).opacity(0)
197+
.font(.system(size: 14))
198+
.frame(maxWidth: .infinity, maxHeight: 400)
199+
.padding(.top, 1)
200+
.padding(.bottom, 2)
201+
.padding(.horizontal, 4)
202+
203+
CustomTextEditor(
204+
text: $provider.requirement,
205+
font: .systemFont(ofSize: 14),
206+
onSubmit: { provider.sendRequirement() }
207+
)
208+
.padding(.top, 1)
209+
.padding(.bottom, -1)
203210
}
204211
.focused($isInputAreaFocused)
205-
.lineLimit(3)
206-
.multilineTextAlignment(.leading)
207-
.textFieldStyle(.plain)
208212
.padding(8)
213+
.fixedSize(horizontal: false, vertical: true)
209214

210215
Button(action: {
211216
provider.sendRequirement()

0 commit comments

Comments
 (0)