Skip to content

Commit 0236e0f

Browse files
committed
fix: keep Shift+Enter inserting new lines in chat input
1 parent 7de61e6 commit 0236e0f

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,8 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
490490
// Handle Enter key based on enterBehavior setting
491491
if (event.key === "Enter" && !isComposing) {
492492
if (enterBehavior === "newline") {
493-
// New behavior: Enter = newline, Shift+Enter or Ctrl+Enter = send
494-
if (event.shiftKey || event.ctrlKey || event.metaKey) {
493+
// New behavior: Enter = newline, Ctrl/Cmd+Enter = send
494+
if (event.ctrlKey || event.metaKey) {
495495
event.preventDefault()
496496
resetHistoryNavigation()
497497
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 send only on Ctrl/Cmd+Enter and allow Shift+Enter 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)
1122+
expect(shiftEnterEvent.defaultPrevented).toBe(false)
11231123
})
11241124
})
11251125
})

0 commit comments

Comments
 (0)