aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/CommandPalette/CommandPalette.svelte18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/CommandPalette/CommandPalette.svelte b/src/lib/CommandPalette/CommandPalette.svelte
index cdf962d7..2d2ec6ee 100644
--- a/src/lib/CommandPalette/CommandPalette.svelte
+++ b/src/lib/CommandPalette/CommandPalette.svelte
@@ -20,14 +20,18 @@
if (!itemIDs.has(item.url)) itemIDs.set(item.url, index);
});
- const doesActionMatch = (action: CommandPaletteAction) =>
- action.name
- .toLowerCase()
- .replace(/\s+/g, '')
- .includes(search.toLowerCase().replace(/\s+/g, '')) ||
- action.tags?.some((tag) =>
- tag.toLowerCase().replace(/\s+/g, '').includes(search.toLowerCase().replace(/\s+/g, ''))
+ const doesActionMatch = (action: CommandPaletteAction) => {
+ const doesActionIncludePattern = (query: string, action: string) => {
+ const normalise = (input: string) => input.toLowerCase().replace(/\s+/g, '');
+
+ return normalise(query).includes(normalise(action));
+ };
+
+ return (
+ doesActionIncludePattern(action.name, search) ||
+ action.tags?.some((tag) => doesActionIncludePattern(tag, search))
);
+ };
filtered = [];