From cc51d2852ea5b4b91dacd7d958466a54b99a2ad2 Mon Sep 17 00:00:00 2001 From: Mathew Pareles Date: Wed, 7 May 2025 19:41:41 -0700 Subject: [PATCH] improve @ to mention --- .../void/browser/react/src/util/inputs.tsx | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx b/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx index 3788e62f..e5d4dad6 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/util/inputs.tsx @@ -185,7 +185,13 @@ const getOptionsAtPath = async (accessor: ReturnType, path: const toolsService = accessor.get('IToolsService') + + console.log('path:' + JSON.stringify(path), ' optionText: ' + optionText) + + + const searchForFilesOrFolders = async (t: string, searchFor: 'files' | 'folders') => { + console.log('AAAA', t, searchFor) try { const searchResults = (await (await toolsService.callTool.search_pathnames_only({ @@ -297,6 +303,7 @@ const getOptionsAtPath = async (accessor: ReturnType, path: let generateNextOptionsAtPath: GenerateNextOptions | undefined = undefined for (const pn of path) { + console.log('BBBB') const selectedOption = nextOptionsAtPath.find(o => o.fullName.toLowerCase() === pn.toLowerCase()) @@ -309,9 +316,12 @@ const getOptionsAtPath = async (accessor: ReturnType, path: if (generateNextOptionsAtPath) { + console.log('CCCC') + nextOptionsAtPath = await generateNextOptionsAtPath(optionText) } else if (path.length === 0 && optionText.trim().length > 0) { // (special case): directly search for both files and folders if optionsPath is empty and there's a search term + console.log('DDDD') const filesResults = await searchForFilesOrFolders(optionText, 'files') || []; const foldersResults = await searchForFilesOrFolders(optionText, 'folders') || []; nextOptionsAtPath = [...foldersResults, ...filesResults,] @@ -371,9 +381,10 @@ export const VoidInputBox2 = forwardRef(fun const [didLoadInitialOptions, setDidLoadInitialOptions] = useState(false); const currentPathRef = useRef(JSON.stringify([])); - // Show breadcrumbs when we have options loaded AND we're either at root level OR in a subfolder - const areBreadcrumbsShowing = true + // dont show breadcrums if first page and user hasnt typed anything + const isTypingEnabled = true + const isBreadcrumbsShowing = optionPath.length === 0 && !optionText ? false : true const insertTextAtCursor = (text: string) => { const textarea = textAreaRef.current; @@ -513,7 +524,7 @@ export const VoidInputBox2 = forwardRef(fun }; }, []); - // debounced + // debounced, but immediate if text is empty const onPathTextChange = useCallback((newStr: string) => { @@ -525,16 +536,24 @@ export const VoidInputBox2 = forwardRef(fun currentPathRef.current = JSON.stringify(optionPath); - // Set a new timeout to fetch options after a delay - debounceTimerRef.current = window.setTimeout(async () => { + const fetchOptions = async () => { const newOpts = await getOptionsAtPath(accessor, optionPath, newStr) || []; if (currentPathRef.current !== JSON.stringify(optionPath)) { return; } setOptions(newOpts); setOptionIdx(0); debounceTimerRef.current = null; - }, 300); + }; + + // If text is empty, run immediately without debouncing + if (newStr.trim() === '') { + fetchOptions(); + } else { + // Otherwise, set a new timeout to fetch options after a delay + debounceTimerRef.current = window.setTimeout(fetchOptions, 300); + } }, [optionPath, accessor]); + const onMenuKeyDown = (e: React.KeyboardEvent) => { const isCommandKeyPressed = e.altKey || e.ctrlKey || e.metaKey; @@ -588,7 +607,7 @@ export const VoidInputBox2 = forwardRef(fun // do nothing } else { // letter - if (areBreadcrumbsShowing) { + if (isTypingEnabled) { onPathTextChange(optionText + e.key) } } @@ -803,7 +822,7 @@ export const VoidInputBox2 = forwardRef(fun onWheel={(e) => e.stopPropagation()} > {/* Breadcrumbs Header */} - {areBreadcrumbsShowing &&
+ {isBreadcrumbsShowing &&
{optionText ?
{/* {optionPath.map((path, index) => (