Complete multi-segment expressions

This commit is contained in:
Beth Brennan
2023-02-07 17:04:47 -05:00
parent 6e236514d5
commit b432867548
7 changed files with 39 additions and 15 deletions
+4 -6
View File
@@ -205,20 +205,18 @@ function getExpressionCompletionItems(
context: DescriptionDictionary,
pos: Position
): CompletionItem[] {
let expressionInput = "";
let currentInput = "";
let relCharPos: number = 0;
if (isBasicExpression(token)) {
expressionInput = currentInput = token.expression;
relCharPos = getRelCharPos(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;
relCharPos = getRelCharPos(stringToken.range!, currentInput, pos);
expressionInput = (getExpressionInput(currentInput, relCharPos) || "").trim();
}
const relCharPos = getRelCharPos(token.range!, currentInput, pos);
const expressionInput = (getExpressionInput(currentInput, relCharPos) || "").trim();
try {
return completeExpression(expressionInput, context, [], validatorFunctions).map(item =>
mapExpressionCompletionItem(item, currentInput[relCharPos])