@@ -20,7 +20,7 @@ import {
2020 SearchResult ,
2121} from "@src/utils/context-mentions"
2222import { cn } from "@src/lib/utils"
23- import { convertToMentionPath } from "@src/utils/path-mentions"
23+ import { convertToMentionPath , escapeSpaces } from "@src/utils/path-mentions"
2424import { StandardTooltip } from "@src/components/ui"
2525
2626import Thumbnails from "../common/Thumbnails"
@@ -354,6 +354,12 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
354354 folderPath = folderPath + "/"
355355 }
356356
357+ // Escape spaces for display (match insertMention behavior)
358+ let displayFolderPath = folderPath
359+ if ( displayFolderPath . includes ( " " ) && ! displayFolderPath . includes ( "\\ " ) ) {
360+ displayFolderPath = escapeSpaces ( displayFolderPath )
361+ }
362+
357363 // Manually build insertion without a trailing space (more deterministic than insertMention)
358364 const original = textAreaRef . current . value
359365 const beforeCursor = original . slice ( 0 , cursorPosition )
@@ -371,9 +377,9 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
371377 afterCursorContent = isAlphaNumSpace ? afterCursor . replace ( / ^ [ ^ \s ] * / , "" ) : afterCursor
372378 }
373379
374- const updatedValue = beforeMention + "@" + folderPath + afterCursorContent
380+ const updatedValue = beforeMention + "@" + displayFolderPath + afterCursorContent
375381 const afterMentionPos =
376- ( lastAtIndex !== - 1 ? lastAtIndex : beforeCursor . length ) + 1 + folderPath . length
382+ ( lastAtIndex !== - 1 ? lastAtIndex : beforeCursor . length ) + 1 + displayFolderPath . length
377383
378384 setInputValue ( updatedValue )
379385 setCursorPosition ( afterMentionPos )
@@ -391,7 +397,8 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
391397 setSearchQuery ( nextQuery )
392398
393399 // Kick off a search to populate folder children
394- const reqId = Math . random ( ) . toString ( 36 ) . substring ( 2 , 9 )
400+ const reqId =
401+ globalThis . crypto ?. randomUUID ?.( ) ?? `${ Date . now ( ) } -${ Math . random ( ) . toString ( 36 ) . slice ( 2 ) } `
395402 setSearchRequestId ( reqId )
396403 setSearchLoading ( true )
397404 vscode . postMessage ( {
@@ -660,7 +667,9 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
660667 // Set a timeout to debounce the search requests.
661668 searchTimeoutRef . current = setTimeout ( ( ) => {
662669 // Generate a request ID for this search.
663- const reqId = Math . random ( ) . toString ( 36 ) . substring ( 2 , 9 )
670+ const reqId =
671+ globalThis . crypto ?. randomUUID ?.( ) ??
672+ `${ Date . now ( ) } -${ Math . random ( ) . toString ( 36 ) . slice ( 2 ) } `
664673 setSearchRequestId ( reqId )
665674 setSearchLoading ( true )
666675
0 commit comments