Skip to content

Commit 48a7d2b

Browse files
committed
Add shortcut shift+enter to add new line in chat
1 parent 480f7ba commit 48a7d2b

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

Core/Sources/SuggestionWidget/SuggestionPanelContent/ChatPanel.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct ChatPanelToolbar: View {
6161

6262
struct ChatPanelMessages: View {
6363
@ObservedObject var chat: ChatProvider
64-
64+
6565
var body: some View {
6666
List {
6767
Group {
@@ -288,12 +288,6 @@ struct ChatPanelInputArea: View {
288288
.multilineTextAlignment(.leading)
289289
.textFieldStyle(.plain)
290290
.padding(8)
291-
.onSubmit {
292-
if chat.isReceivingMessage { return }
293-
if typedMessage.isEmpty { return }
294-
chat.send(typedMessage)
295-
typedMessage = ""
296-
}
297291

298292
Button(action: {
299293
if typedMessage.isEmpty { return }
@@ -305,6 +299,7 @@ struct ChatPanelInputArea: View {
305299
}
306300
.buttonStyle(.plain)
307301
.disabled(chat.isReceivingMessage)
302+
.keyboardShortcut(KeyEquivalent.return, modifiers: [])
308303
}
309304
.frame(maxWidth: .infinity)
310305
.background {
@@ -315,6 +310,14 @@ struct ChatPanelInputArea: View {
315310
RoundedRectangle(cornerRadius: 6)
316311
.stroke(Color(nsColor: .controlColor), lineWidth: 1)
317312
}
313+
.background {
314+
Button(action: {
315+
typedMessage += "\n"
316+
}) {
317+
EmptyView()
318+
}
319+
.keyboardShortcut(KeyEquivalent.return, modifiers: [.shift])
320+
}
318321
}
319322
.onAppear {
320323
isInputAreaFocused = true
@@ -536,3 +539,4 @@ struct ChatPanel_Light_Preview: PreviewProvider {
536539
.colorScheme(.light)
537540
}
538541
}
542+

0 commit comments

Comments
 (0)