Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions webview-ui/src/components/chat/ChatTextArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,15 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
let newValue = inputValue.slice(0, cursorPosition)
let totalLength = 0

// Check if we need to add a space before the first mention
const textBefore = inputValue.slice(0, cursorPosition)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This space-checking logic is duplicated in the insertMention function. Since insertMention already handles adding space before @mentions, do we need this logic here as well?

Consider whether both places need this or if it should be centralized in one location to avoid potential inconsistencies.

const needsSpaceBefore =
textBefore.length > 0 && !textBefore.endsWith(" ") && !textBefore.endsWith("\n")
if (needsSpaceBefore) {
newValue += " "
totalLength += 1
}

// Using a standard for loop instead of forEach for potential performance gains.
for (let i = 0; i < lines.length; i++) {
const line = lines[i]
Expand Down
Loading
Loading