feat: add filtering support for @ command selector in goto-anything (#23763)
This commit is contained in:
parent
a44ca29717
commit
2944a4fd43
3 changed files with 378 additions and 4 deletions
|
|
@ -82,7 +82,7 @@ const GotoAnything: FC<Props> = ({
|
|||
wait: 300,
|
||||
})
|
||||
|
||||
const isCommandsMode = searchQuery.trim() === '@'
|
||||
const isCommandsMode = searchQuery.trim() === '@' || (searchQuery.trim().startsWith('@') && !matchAction(searchQuery.trim(), Actions))
|
||||
|
||||
const searchMode = useMemo(() => {
|
||||
if (isCommandsMode) return 'commands'
|
||||
|
|
@ -253,8 +253,9 @@ const GotoAnything: FC<Props> = ({
|
|||
value={searchQuery}
|
||||
placeholder={t('app.gotoAnything.searchPlaceholder')}
|
||||
onChange={(e) => {
|
||||
setCmdVal('')
|
||||
setSearchQuery(e.target.value)
|
||||
if (!e.target.value.startsWith('@'))
|
||||
setCmdVal('')
|
||||
}}
|
||||
className='flex-1 !border-0 !bg-transparent !shadow-none'
|
||||
wrapperClassName='flex-1 !border-0 !bg-transparent'
|
||||
|
|
@ -301,6 +302,9 @@ const GotoAnything: FC<Props> = ({
|
|||
<CommandSelector
|
||||
actions={Actions}
|
||||
onCommandSelect={handleCommandSelect}
|
||||
searchFilter={searchQuery.trim().substring(1)}
|
||||
commandValue={cmdVal}
|
||||
onCommandValueChange={setCmdVal}
|
||||
/>
|
||||
) : (
|
||||
Object.entries(groupedResults).map(([type, results], groupIndex) => (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue