mirror of
https://github.com/wavetermdev/inshellisense.git
synced 2026-08-05 13:43:30 -07:00
fix: subCommands find problem (#179)
* fix: subCommands find problem * Update src/runtime/runtime.ts * Update src/runtime/runtime.ts * style: fix linting --------- Signed-off-by: Chapman Pendery <cpendery@microsoft.com>
This commit is contained in:
@@ -113,10 +113,12 @@ const getSubcommand = (spec?: Fig.Spec): Fig.Subcommand | undefined => {
|
||||
const executeShellCommand = buildExecuteShellCommand(5000);
|
||||
|
||||
const genSubcommand = async (command: string, parentCommand: Fig.Subcommand): Promise<Fig.Subcommand | undefined> => {
|
||||
const subcommandIdx = parentCommand.subcommands?.findIndex((s) => s.name === command);
|
||||
if (subcommandIdx == null) return;
|
||||
const subcommand = parentCommand.subcommands?.at(subcommandIdx);
|
||||
if (subcommand == null) return;
|
||||
if (!parentCommand.subcommands || parentCommand.subcommands.length === 0) return;
|
||||
|
||||
const subcommandIdx = parentCommand.subcommands.findIndex((s) => (Array.isArray(s.name) ? s.name.includes(command) : s.name === command));
|
||||
|
||||
if (subcommandIdx === -1) return;
|
||||
const subcommand = parentCommand.subcommands[subcommandIdx];
|
||||
|
||||
// this pulls in the spec from the load spec and overwrites the subcommand in the parent with the loaded spec.
|
||||
// then it returns the subcommand and clears the loadSpec field so that it doesn't get called again
|
||||
|
||||
Reference in New Issue
Block a user