fix: slash command prefix matching
This commit is contained in:
parent
c62cbdc21e
commit
0a402010d9
1 changed files with 10 additions and 3 deletions
|
|
@ -61,10 +61,17 @@ const SlashCommandUI: React.FC<SlashCommandUIProps> = ({
|
||||||
const allCommands = getSlashCommands();
|
const allCommands = getSlashCommands();
|
||||||
|
|
||||||
// Filter commands based on the current filter
|
// Filter commands based on the current filter
|
||||||
const filteredCommands = allCommands.filter((cmd) =>
|
const filteredCommands = allCommands
|
||||||
cmd.name.toLowerCase().includes(filter.toLowerCase())
|
.filter((cmd) => cmd.name.toLowerCase().includes(filter.toLowerCase()))
|
||||||
);
|
.sort((a, b) => {
|
||||||
|
const aStartsWith = a.name.toLowerCase().startsWith(filter.toLowerCase());
|
||||||
|
const bStartsWith = b.name.toLowerCase().startsWith(filter.toLowerCase());
|
||||||
|
|
||||||
|
if (aStartsWith && !bStartsWith) return -1;
|
||||||
|
if (!aStartsWith && bStartsWith) return 1;
|
||||||
|
|
||||||
|
return a.name.localeCompare(b.name);
|
||||||
|
});
|
||||||
if (filteredCommands.length === 0) {
|
if (filteredCommands.length === 0) {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue