Skip to content
Open
Changes from all commits
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
4 changes: 3 additions & 1 deletion cmdk/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ const Command = React.forwardRef<HTMLDivElement, CommandProps>((props, forwarded

function score(value: string, keywords?: string[]) {
const filter = propsRef.current?.filter ?? defaultFilter
return value ? filter(value, state.current.search, keywords) : 0
const search = state.current.search ?? ''
const sanitizedSearch = search.replace(/\s+/g, ' ').trim()
return value ? filter(value, sanitizedSearch, keywords) : 0
}

/** Sorts items by score, and groups by highest item score. */
Expand Down