Skip to content

Commit e31c85a

Browse files
committed
Add shortcut command+w to cancel prompt to code and shift+enter to add new line
1 parent 78fe12b commit e31c85a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

Core/Sources/SuggestionWidget/SuggestionPanelContent/PromptToCodePanel.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ struct PromptToCodePanel: View {
5959
provider.cancel()
6060
}) {
6161
Text("Cancel")
62-
}.buttonStyle(CommandButtonStyle(color: .gray))
62+
}
63+
.buttonStyle(CommandButtonStyle(color: .gray))
64+
.keyboardShortcut("w", modifiers: [.command])
6365

6466
if !provider.code.isEmpty {
6567
Button(action: {
@@ -149,7 +151,7 @@ struct PromptToCodePanelContent: View {
149151
.frame(maxWidth: .infinity)
150152
.scaleEffect(x: -1, y: -1, anchor: .center)
151153
}
152-
154+
153155
if let name = provider.name {
154156
Text(name)
155157
.font(.footnote)
@@ -204,9 +206,6 @@ struct PromptToCodePanelToolbar: View {
204206
.multilineTextAlignment(.leading)
205207
.textFieldStyle(.plain)
206208
.padding(8)
207-
.onSubmit {
208-
provider.sendRequirement()
209-
}
210209

211210
Button(action: {
212211
provider.sendRequirement()
@@ -216,6 +215,7 @@ struct PromptToCodePanelToolbar: View {
216215
}
217216
.buttonStyle(.plain)
218217
.disabled(provider.isResponding)
218+
.keyboardShortcut(KeyEquivalent.return, modifiers: [])
219219
}
220220
.frame(maxWidth: .infinity)
221221
.background {
@@ -226,6 +226,14 @@ struct PromptToCodePanelToolbar: View {
226226
RoundedRectangle(cornerRadius: 6)
227227
.stroke(Color(nsColor: .controlColor), lineWidth: 1)
228228
}
229+
.background {
230+
Button(action: {
231+
provider.requirement += "\n"
232+
}) {
233+
EmptyView()
234+
}
235+
.keyboardShortcut(KeyEquivalent.return, modifiers: [.shift])
236+
}
229237
}
230238
.onAppear {
231239
isInputAreaFocused = true
@@ -277,3 +285,4 @@ struct PromptToCodePanel_Error_Bright_Preview: PreviewProvider {
277285
.frame(width: 450, height: 400)
278286
}
279287
}
288+

0 commit comments

Comments
 (0)