diff --git a/index.html b/index.html
index d5bc40d..0aafda7 100644
--- a/index.html
+++ b/index.html
@@ -49,8 +49,8 @@
// prettier-ignore
const COMMANDS = new Map([
- ['a', { name: 'AI', suggestions: ['a/chat', 'a/gemini', 'a/grok', 'a/lumo'], url: 'https://claude.ai/new' }],
- ['a/chat', { url: 'https://chatgpt.com' }],
+ ['a', { name: 'AI', suggestions: ['a/chatgpt', 'a/gemini', 'a/grok', 'a/lumo'], url: 'https://claude.ai/new' }],
+ ['a/chatgpt', { url: 'https://chatgpt.com' }],
['a/gemini', { url: 'https://gemini.google.com' }],
['a/grok', { url: 'https://grok.com' }],
['a/lumo', { url: 'https://lumo.proton.me/u/0' }],
@@ -451,21 +451,34 @@
return;
}
- let suggestions = COMMANDS.get(oq.query)?.suggestions ?? [];
+ const parentKey = oq.query.split(CONFIG.commandPathDelimiter)[0];
- if (
- oq.search?.length > 1 &&
- suggestions.length < CONFIG.suggestionLimit
- ) {
+ let suggestions = [
+ ...(COMMANDS.get(oq.query)?.suggestions ??
+ COMMANDS.get(parentKey)?.suggestions ??
+ []),
+ ];
+
+ for (const key of COMMANDS.keys()) {
+ if (
+ key.startsWith(oq.query) &&
+ key !== oq.query &&
+ !suggestions.includes(key)
+ ) {
+ suggestions.push(key);
+ }
+ }
+
+ suggestions = suggestions.filter((s) => s.startsWith(oq.query));
+
+ if (oq.search?.length > 1 && suggestions.length === 0) {
const res = await Search.#fetchDuckDuckGoSuggestions(oq.search);
- suggestions = suggestions
- .concat(
- oq.splitBy
- ? res.map((search) => `${oq.key}${oq.splitBy}${search}`)
- : res
- )
- .slice(0, CONFIG.suggestionLimit);
+ suggestions = oq.splitBy
+ ? res.map((search) => `${oq.key}${oq.splitBy}${search}`)
+ : res;
+
+ suggestions = suggestions.slice(0, CONFIG.suggestionLimit);
}
const nq = Search.#parseQuery(this.#input.value);