2022-10-10 12:50:21 +00:00
|
|
|
import { matchBefore } from "../../syscall/silverbullet-syscall/editor.ts";
|
|
|
|
import { listCommands } from "../../syscall/silverbullet-syscall/system.ts";
|
2022-09-06 12:36:06 +00:00
|
|
|
|
|
|
|
export async function commandComplete() {
|
|
|
|
let prefix = await matchBefore("\\{\\[[^\\]]*");
|
|
|
|
if (!prefix) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
let allCommands = await listCommands();
|
|
|
|
|
|
|
|
return {
|
|
|
|
from: prefix.from + 2,
|
|
|
|
options: Object.keys(allCommands).map((commandName) => ({
|
|
|
|
label: commandName,
|
|
|
|
type: "command",
|
|
|
|
})),
|
|
|
|
};
|
|
|
|
}
|