mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-17 23:51:08 +00:00
Merge 1918d9cfe6 into c4547d25c5
This commit is contained in:
commit
d832844373
1 changed files with 14 additions and 11 deletions
|
|
@ -245,7 +245,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||
}, [selectedType, searchQuery])
|
||||
|
||||
const handleEnhancePrompt = useCallback(() => {
|
||||
const trimmedInput = inputValue.trim()
|
||||
const trimmedInput = (inputValue ?? "").trim()
|
||||
|
||||
if (trimmedInput) {
|
||||
setIsEnhancingPrompt(true)
|
||||
|
|
@ -259,7 +259,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||
|
||||
// Memoized check for whether the input has content (text or images)
|
||||
const hasInputContent = useMemo(() => {
|
||||
return inputValue.trim().length > 0 || selectedImages.length > 0
|
||||
return (inputValue ?? "").trim().length > 0 || selectedImages.length > 0
|
||||
}, [inputValue, selectedImages])
|
||||
|
||||
// Compute the key combination text for the send button tooltip based on enterBehavior
|
||||
|
|
@ -509,8 +509,9 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||
}
|
||||
|
||||
if (event.key === "Backspace" && !isComposing) {
|
||||
const charBeforeCursor = inputValue[cursorPosition - 1]
|
||||
const charAfterCursor = inputValue[cursorPosition + 1]
|
||||
const safeInputValue = inputValue ?? ""
|
||||
const charBeforeCursor = safeInputValue[cursorPosition - 1]
|
||||
const charAfterCursor = safeInputValue[cursorPosition + 1]
|
||||
|
||||
const charBeforeIsWhitespace =
|
||||
charBeforeCursor === " " || charBeforeCursor === "\n" || charBeforeCursor === "\r\n"
|
||||
|
|
@ -522,7 +523,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||
if (
|
||||
charBeforeIsWhitespace &&
|
||||
// "$" is added to ensure the match occurs at the end of the string.
|
||||
inputValue.slice(0, cursorPosition - 1).match(new RegExp(mentionRegex.source + "$"))
|
||||
safeInputValue.slice(0, cursorPosition - 1).match(new RegExp(mentionRegex.source + "$"))
|
||||
) {
|
||||
const newCursorPosition = cursorPosition - 1
|
||||
// If mention is followed by another word, then instead
|
||||
|
|
@ -537,9 +538,9 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||
setCursorPosition(newCursorPosition)
|
||||
setJustDeletedSpaceAfterMention(true)
|
||||
} else if (justDeletedSpaceAfterMention) {
|
||||
const { newText, newPosition } = removeMention(inputValue, cursorPosition)
|
||||
|
||||
if (newText !== inputValue) {
|
||||
const { newText, newPosition } = removeMention(safeInputValue, cursorPosition)
|
||||
|
||||
if (newText !== safeInputValue) {
|
||||
event.preventDefault()
|
||||
setInputValue(newText)
|
||||
setIntendedCursorPosition(newPosition) // Store the new cursor position in state
|
||||
|
|
@ -677,8 +678,9 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||
if (urlRegex.test(pastedText.trim())) {
|
||||
e.preventDefault()
|
||||
const trimmedUrl = pastedText.trim()
|
||||
const safeInputValue = inputValue ?? ""
|
||||
const newValue =
|
||||
inputValue.slice(0, cursorPosition) + trimmedUrl + " " + inputValue.slice(cursorPosition)
|
||||
safeInputValue.slice(0, cursorPosition) + trimmedUrl + " " + safeInputValue.slice(cursorPosition)
|
||||
setInputValue(newValue)
|
||||
const newCursorPosition = cursorPosition + trimmedUrl.length + 1
|
||||
setCursorPosition(newCursorPosition)
|
||||
|
|
@ -823,7 +825,8 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||
|
||||
if (lines.length > 0) {
|
||||
// Process each line as a separate file path
|
||||
let newValue = inputValue.slice(0, cursorPosition)
|
||||
const safeInputValue = inputValue ?? ""
|
||||
let newValue = safeInputValue.slice(0, cursorPosition)
|
||||
let totalLength = 0
|
||||
|
||||
// Using a standard for loop instead of forEach for potential performance gains.
|
||||
|
|
@ -842,7 +845,7 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||
}
|
||||
|
||||
// Add space after the last mention and append the rest of the input
|
||||
newValue += " " + inputValue.slice(cursorPosition)
|
||||
newValue += " " + safeInputValue.slice(cursorPosition)
|
||||
totalLength += 1
|
||||
|
||||
setInputValue(newValue)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue