Merge branch 'main' into joshmgross/improve-expression-completion
This commit is contained in:
@@ -3,7 +3,7 @@ import {convertWorkflowTemplate, isSequence, isString, parseWorkflow} from "@git
|
||||
import {ErrorPolicy} from "@github/actions-workflow-parser/model/convert";
|
||||
import {DefinitionType} from "@github/actions-workflow-parser/templates/schema/definition-type";
|
||||
import {StringDefinition} from "@github/actions-workflow-parser/templates/schema/string-definition";
|
||||
import {CLOSE_EXPRESSION, OPEN_EXPRESSION} from "@github/actions-workflow-parser/templates/template-constants";
|
||||
import {OPEN_EXPRESSION} from "@github/actions-workflow-parser/templates/template-constants";
|
||||
import {TemplateToken} from "@github/actions-workflow-parser/templates/tokens/index";
|
||||
import {MappingToken} from "@github/actions-workflow-parser/templates/tokens/mapping-token";
|
||||
import {TokenType} from "@github/actions-workflow-parser/templates/tokens/types";
|
||||
@@ -14,7 +14,6 @@ import {ContextProviderConfig} from "./context-providers/config";
|
||||
import {getContext, Mode} from "./context-providers/default";
|
||||
import {getWorkflowContext, WorkflowContext} from "./context/workflow-context";
|
||||
import {nullTrace} from "./nulltrace";
|
||||
import {getAllowedContext} from "./utils/allowed-context";
|
||||
import {findToken} from "./utils/find-token";
|
||||
import {mapRange} from "./utils/range";
|
||||
import {transform} from "./utils/transform";
|
||||
@@ -29,14 +28,7 @@ export function getExpressionInput(input: string, pos: number): string {
|
||||
return input;
|
||||
}
|
||||
|
||||
// Find end marker after the cursor position
|
||||
let endPos = input.indexOf(CLOSE_EXPRESSION, pos);
|
||||
if (endPos === -1) {
|
||||
// Assume an unfinished expression like "${{ someinput.|"
|
||||
endPos = input.length;
|
||||
}
|
||||
|
||||
return input.substring(startPos + OPEN_EXPRESSION.length, endPos);
|
||||
return input.substring(startPos + OPEN_EXPRESSION.length, pos);
|
||||
}
|
||||
|
||||
export async function complete(
|
||||
@@ -85,14 +77,14 @@ export async function complete(
|
||||
if (token.range!.start[0] !== token.range!.end[0]) {
|
||||
const lines = currentInput.split("\n");
|
||||
const linesBeforeCusor = lines.slice(0, lineDiff);
|
||||
relCharPos = linesBeforeCusor.join("\n").length + newPos.character;
|
||||
relCharPos = linesBeforeCusor.join("\n").length + 1 + newPos.character;
|
||||
} else {
|
||||
relCharPos = newPos.character - token.range!.start[1];
|
||||
relCharPos = newPos.character - token.range!.start[1] + 1;
|
||||
}
|
||||
|
||||
const expressionInput = (getExpressionInput(currentInput, relCharPos) || "").trim();
|
||||
|
||||
const allowedContext = getAllowedContext(token, parent);
|
||||
const allowedContext = token.definitionInfo?.allowedContext || [];
|
||||
const context = await getContext(allowedContext, contextProviderConfig, workflowContext, Mode.Completion);
|
||||
|
||||
return completeExpression(expressionInput, context, []).map(item => {
|
||||
|
||||
Reference in New Issue
Block a user