Не подтверждена Коммит 42f72841 создал по автору Daniel Imms's avatar Daniel Imms
Просмотр файлов

Clean up adding items and classifying options and option values

владелец edfcc410
......@@ -256,51 +256,46 @@ export async function collectCompletionItemResult(
return { filesRequested, foldersRequested };
}
const flagsToExclude = kind === vscode.TerminalCompletionItemKind.Flag ? parsedArguments?.passedOptions.map(option => option.name).flat() : undefined;
if (Array.isArray(specArgs)) {
function addItem(label: string, item: SpecArg) {
if (flagsToExclude?.includes(label)) {
return;
}
let itemKind = kind;
if (parsedArguments?.currentArg?.suggestions?.length === specArgs.length) {
if (typeof item === 'object' && 'args' in item && (asArray(item.args ?? [])).length > 0) {
itemKind = vscode.TerminalCompletionItemKind.Option;
}
const lastArgType: string | undefined = parsedArguments?.annotations.at(-1)?.type;
if (lastArgType === 'option_arg') {
itemKind = vscode.TerminalCompletionItemKind.OptionValue;
}
items.push(
createCompletionItem(
terminalContext.cursorPosition,
prefix,
{ label },
undefined,
typeof item === 'string' ? item : item.description,
itemKind,
)
);
}
if (Array.isArray(specArgs)) {
for (const item of specArgs) {
const suggestionLabels = getFigSuggestionLabel(item);
if (!suggestionLabels?.length) {
continue;
}
for (const label of suggestionLabels) {
if (flagsToExclude?.includes(label)) {
continue;
}
items.push(
createCompletionItem(
terminalContext.cursorPosition,
prefix,
{ label },
undefined,
typeof item === 'string' ? item : item.description,
itemKind
)
);
addItem(label, item);
}
}
} else {
for (const [label, item] of Object.entries(specArgs)) {
if (flagsToExclude?.includes(label)) {
continue;
}
let itemKind = kind;
if (typeof item === 'object' && 'args' in item && (asArray(item.args ?? [])).length > 0) {
itemKind = vscode.TerminalCompletionItemKind.Option;
}
items.push(
createCompletionItem(
terminalContext.cursorPosition,
prefix,
{ label },
undefined,
typeof item === 'string' ? item : item.description,
itemKind,
)
);
addItem(label, item);
}
}
};
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать