From b9871310a42ec53ed75e60c609424d4bb1b7fc2d Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Mon, 16 Sep 2024 18:41:40 -0400 Subject: [PATCH] Select top result by default --- webview-ui/src/components/ChatTextArea.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/webview-ui/src/components/ChatTextArea.tsx b/webview-ui/src/components/ChatTextArea.tsx index a874712..8639a5f 100644 --- a/webview-ui/src/components/ChatTextArea.tsx +++ b/webview-ui/src/components/ChatTextArea.tsx @@ -206,8 +206,13 @@ const ChatTextArea = forwardRef( setShowContextMenu(showMenu) if (showMenu) { const lastAtIndex = newValue.lastIndexOf("@", newCursorPosition - 1) - setSearchQuery(newValue.slice(lastAtIndex + 1, newCursorPosition)) - setSelectedMenuIndex(2) // Set to "File" option by default + const query = newValue.slice(lastAtIndex + 1, newCursorPosition) + setSearchQuery(query) + if (query.length > 0) { + setSelectedMenuIndex(0) + } else { + setSelectedMenuIndex(2) // Set to "File" option by default + } } else { setSearchQuery("") setSelectedMenuIndex(-1)