Merge branch 'main' into joshmgross/reusable-wf-outputs

This commit is contained in:
Josh Gross
2023-02-08 10:39:31 -05:00
10 changed files with 42 additions and 37 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@github/actions-languageservice",
"version": "0.1.127",
"version": "0.1.129",
"description": "Language service for GitHub Actions",
"license": "MIT",
"type": "module",
@@ -38,8 +38,8 @@
"watch": "tsc --build tsconfig.build.json --watch"
},
"dependencies": {
"@github/actions-expressions": "^0.1.127",
"@github/actions-workflow-parser": "^0.1.127",
"@github/actions-expressions": "^0.1.129",
"@github/actions-workflow-parser": "^0.1.129",
"vscode-languageserver-textdocument": "^1.0.7",
"vscode-languageserver-types": "^3.17.2",
"yaml": "^2.1.1"
@@ -278,6 +278,13 @@ jobs:
expect(result.map(x => x.label)).toEqual(["event"]);
});
it("auto-complete complex partial", async () => {
const input = 'run-name: "run ${{ github.ev| }} run"';
const result = await complete(...getPositionFromCursor(input), undefined, contextProviderConfig);
expect(result.map(x => x.label)).toEqual(["event"]);
});
it("using default context provider", async () => {
const input =
"on: push\njobs:\n build:\n runs-on: ubuntu-latest\n environment:\n url: ${{ runner.| }}\n steps:\n - run: echo";
+4 -6
View File
@@ -217,20 +217,18 @@ function getExpressionCompletionItems(
context: DescriptionDictionary,
pos: Position
): CompletionItem[] {
let expressionInput = "";
let currentInput = "";
let relCharOffset: number = 0;
if (isBasicExpression(token)) {
expressionInput = currentInput = token.expression;
relCharOffset = getRelCharOffset(token.range!, expressionInput, pos);
currentInput = token.source || token.expression;
} else {
const stringToken = token.assertString("Expected string token for expression completion");
currentInput = stringToken.source || stringToken.value;
relCharOffset = getRelCharOffset(stringToken.range!, currentInput, pos);
expressionInput = (getExpressionInput(currentInput, relCharOffset) || "").trim();
}
const relCharOffset = getRelCharOffset(token.range!, currentInput, pos);
const expressionInput = (getExpressionInput(currentInput, relCharOffset) || "").trim();
try {
return completeExpression(expressionInput, context, [], validatorFunctions).map(item =>
mapExpressionCompletionItem(item, currentInput[relCharOffset])