Expand one-of keys to multiple completion items (#261)
* Expand one-of keys to multiple completion items Some workflow fields accept multiple YAML structures (scalar, sequence, or mapping), but completions previously only showed a single option—leaving users unaware of the full schema flexibility. This change surfaces structural options and inserts the correct YAML scaffolding so users land in the right place to keep typing. Example: runs-on Completing runs-on now shows three options: - runs-on → Ready for a string like ubuntu-latest - runs-on (list) → Ready to add runner labels - runs-on (full syntax) → Ready for labels:, group:, etc. Notes: - Qualifiers (list) and (full syntax) only appear when multiple structural types exist - Scalar completions use the plain key name - Qualified variants use filterText matching the base key * Sort expanded one-of completions: scalar, list, full syntax
This commit is contained in:
@@ -129,6 +129,8 @@ export async function complete(
|
||||
|
||||
const item: CompletionItem = {
|
||||
label: value.label,
|
||||
filterText: value.filterText,
|
||||
sortText: value.sortText,
|
||||
documentation: value.description && {
|
||||
kind: "markdown",
|
||||
value: value.description
|
||||
@@ -253,7 +255,7 @@ function getExpressionCompletionItems(
|
||||
|
||||
function filterAndSortCompletionOptions(options: Value[], existingValues?: Set<string>) {
|
||||
options = options.filter(x => !existingValues?.has(x.label));
|
||||
options.sort((a, b) => a.label.localeCompare(b.label));
|
||||
options.sort((a, b) => (a.sortText ?? a.label).localeCompare(b.sortText ?? b.label));
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user