Merge pull request #31 from github/cschleiden/sequence-auto-completion
Support auto-completion in sequences
This commit is contained in:
@@ -263,6 +263,31 @@ jobs:
|
||||
expect(result).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("empty step", async () => {
|
||||
const input = `on: push
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo
|
||||
- |`;
|
||||
const result = await complete(...getPositionFromCursor(input));
|
||||
expect(result).toHaveLength(11);
|
||||
expect(result.map(x => x.label)).toEqual([
|
||||
"continue-on-error",
|
||||
"env",
|
||||
"id",
|
||||
"if",
|
||||
"name",
|
||||
"run",
|
||||
"shell",
|
||||
"timeout-minutes",
|
||||
"uses",
|
||||
"with",
|
||||
"working-directory"
|
||||
]);
|
||||
});
|
||||
|
||||
it("loose mapping keys have no completion suggestions", async () => {
|
||||
const input = `
|
||||
on:
|
||||
|
||||
@@ -2,6 +2,7 @@ import {BooleanDefinition} from "@github/actions-workflow-parser/templates/schem
|
||||
import {Definition} from "@github/actions-workflow-parser/templates/schema/definition";
|
||||
import {MappingDefinition} from "@github/actions-workflow-parser/templates/schema/mapping-definition";
|
||||
import {OneOfDefinition} from "@github/actions-workflow-parser/templates/schema/one-of-definition";
|
||||
import {SequenceDefinition} from "@github/actions-workflow-parser/templates/schema/sequence-definition";
|
||||
import {StringDefinition} from "@github/actions-workflow-parser/templates/schema/string-definition";
|
||||
import {getWorkflowSchema} from "@github/actions-workflow-parser/workflows/workflow-schema";
|
||||
import {Value} from "./config";
|
||||
@@ -26,6 +27,13 @@ export function definitionValues(def: Definition): Value[] {
|
||||
return stringsToValues([def.constant]);
|
||||
}
|
||||
|
||||
if (def instanceof SequenceDefinition) {
|
||||
const itemDef = schema.getDefinition(def.itemType);
|
||||
if (itemDef) {
|
||||
return definitionValues(itemDef);
|
||||
}
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user