From ccb1e7356031f4d050a59a5743dde43ecc089acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20=28Netux=29=20Rodr=C3=ADguez?= Date: Sun, 28 Jan 2024 19:14:10 -0300 Subject: [PATCH] style(editor compiler): expand abbreviations in variable names --- app/javascript/src/utils/compiler/for.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/javascript/src/utils/compiler/for.js b/app/javascript/src/utils/compiler/for.js index 04cd24de0..95e52b426 100644 --- a/app/javascript/src/utils/compiler/for.js +++ b/app/javascript/src/utils/compiler/for.js @@ -4,15 +4,15 @@ export function evaluateForLoops(joinedItems) { let match const forRegex = /@for\s+\(\s*((?:(\w+)\s+)?(?:from\s+))?(\d+)\s+(?:(through|to)\s+)?(\d+)(?:\s*in steps of\s+(\d+))?\s*\)\s*\{/g // Matches "@for ([var] [from] number through|to number [in steps of number]) {" in groups for each param while ((match = forRegex.exec(joinedItems)) != null) { - const [full, _, variable, startStr, clusivityKw, endStr, stepStr = "1"] = match + const [full, _, variable, startString, clusivityKeyword, endString, stepString = "1"] = match - const inclusive = clusivityKw === "through" + const inclusive = clusivityKeyword === "through" const openingBracketIndex = match.index + full.length - 1 const closingBracketIndex = getClosingBracket(joinedItems, "{", "}", openingBracketIndex - 1) const content = joinedItems.substring(openingBracketIndex + 1, closingBracketIndex) - const [start, end, step] = [parseInt(startStr), parseInt(endStr), parseInt(stepStr)] + const [start, end, step] = [parseInt(startString), parseInt(endString), parseInt(stepString)] if (step === 0) throw new Error("For loop would cause an infinite loop") // Replace "For.[variable]" with the current index