New structure and more tabbing

This commit is contained in:
2021-12-15 18:56:32 +01:00
parent b99bdb366c
commit ced2559551
4 changed files with 26 additions and 14 deletions

View File

@ -1,7 +1,7 @@
const commandList = ["about", "navigate", "external", "help", "ed", "nano"];
export function commandCompletion(input: string): string {
if (input === "") return "";
const candidates = commandList.map((cmd) => [cmd.substring(0, input.length), cmd]).filter((cmd) => cmd[0] === input);
return candidates.length > 0 ? candidates[0][1] : "";
export function commandCompletion(input: string): string[] {
if (input === "") return [];
const candidates = commandList.filter((cmd) => cmd.substring(0, input.length) === input);
return candidates;
}