Skip to content

Commit 08ce747

Browse files
committed
fix: Shift+Enter inserts newline instead of sending when Ctrl+Enter mode is enabled
Removes event.shiftKey from the send condition in ChatTextArea when enterBehavior is "newline", so that only Ctrl/Cmd+Enter sends the message. Shift+Enter and plain Enter now both insert newlines as expected. Fixes #10386
1 parent 137d3f4 commit 08ce747

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

webview-ui/src/components/chat/ChatTextArea.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
491491
// Handle Enter key based on enterBehavior setting
492492
if (event.key === "Enter" && !isComposing) {
493493
if (enterBehavior === "newline") {
494-
// New behavior: Enter = newline, Shift+Enter or Ctrl+Enter = send
495-
if (event.shiftKey || event.ctrlKey || event.metaKey) {
494+
// New behavior: Enter/Shift+Enter = newline, Ctrl/Cmd+Enter = send
495+
if (event.ctrlKey || event.metaKey) {
496496
event.preventDefault()
497497
resetHistoryNavigation()
498498
onSend()

webview-ui/src/components/chat/__tests__/ChatTextArea.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ describe("ChatTextArea", () => {
10811081
expect(shiftEnterEvent.defaultPrevented).toBe(false)
10821082
})
10831083

1084-
it("should treat Ctrl/Cmd/Shift+Enter as send and plain Enter as newline in newline mode", () => {
1084+
it("should treat Ctrl/Cmd+Enter as send and plain Enter/Shift+Enter as newline in newline mode", () => {
10851085
const onSend = vi.fn()
10861086

10871087
;(useExtensionState as ReturnType<typeof vi.fn>).mockReturnValue({
@@ -1118,8 +1118,8 @@ describe("ChatTextArea", () => {
11181118
cancelable: true,
11191119
})
11201120
fireEvent(textarea, shiftEnterEvent)
1121-
expect(onSend).toHaveBeenCalledTimes(2)
1122-
expect(shiftEnterEvent.defaultPrevented).toBe(true)
1121+
expect(onSend).toHaveBeenCalledTimes(1) // Shift+Enter should NOT send
1122+
expect(shiftEnterEvent.defaultPrevented).toBe(false) // Should allow newline
11231123
})
11241124
})
11251125
})

0 commit comments

Comments
 (0)