(key: any)
| 552 | }; |
| 553 | |
| 554 | const handleEnterKey = (key: any): boolean => { |
| 555 | if (key.return && !key.shift) { |
| 556 | // Check for backslash continuation |
| 557 | const beforeCursor = textBuffer.text.slice(0, cursorPosition); |
| 558 | const trimmedBeforeCursor = beforeCursor.trimEnd(); |
| 559 | |
| 560 | if (trimmedBeforeCursor.endsWith("\\")) { |
| 561 | // Handle backslash continuation: remove the trailing "\" and add newline |
| 562 | const beforeBackslash = trimmedBeforeCursor.slice(0, -1); |
| 563 | const afterCursor = textBuffer.text.slice(cursorPosition); |
| 564 | const newText = beforeBackslash + "\n" + afterCursor; |
| 565 | const newCursorPos = beforeBackslash.length + 1; |
| 566 | |
| 567 | textBuffer.setText(newText); |
| 568 | textBuffer.setCursor(newCursorPos); |
| 569 | setInputText(newText); |
| 570 | setCursorPosition(newCursorPos); |
| 571 | updateSlashCommandState(newText, newCursorPos); |
| 572 | updateFileSearchState(newText, newCursorPos); |
| 573 | return true; |
| 574 | } |
| 575 | |
| 576 | // Normal Enter behavior - submit if there's content |
| 577 | if (textBuffer.text.trim() || wasInterrupted) { |
| 578 | // Get images before expanding paste blocks |
| 579 | const imageMap = textBuffer.getAllImages(); |
| 580 | |
| 581 | // Expand all paste blocks before submitting |
| 582 | textBuffer.expandAllPasteBlocks(); |
| 583 | const submittedText = textBuffer.text.trim(); |
| 584 | |
| 585 | inputHistory.addEntry(submittedText); |
| 586 | |
| 587 | // We don't queue, we just send in remote mode because the server handles queueing |
| 588 | if (!isRemoteMode && (isWaitingForResponse || isCompacting)) { |
| 589 | // Process message later when LLM has responded or compaction is complete |
| 590 | void messageQueue.enqueueMessage(submittedText, imageMap); |
| 591 | } else { |
| 592 | // Submit with images |
| 593 | onSubmit(submittedText, imageMap); |
| 594 | } |
| 595 | |
| 596 | textBuffer.clear(); |
| 597 | setInputText(""); |
| 598 | setCursorPosition(0); |
| 599 | setShowSlashCommands(false); |
| 600 | setShowBashMode(false); |
| 601 | } |
| 602 | return true; |
| 603 | } |
| 604 | return false; |
| 605 | }; |
| 606 | |
| 607 | const handleNewLine = (input: string, key: any): boolean => { |
| 608 | if (input === "\r" || input === "\\\r") { |
no test coverage detected