From 05e69f9854daab7f6d2811fcae3ce74095a9cafe Mon Sep 17 00:00:00 2001 From: YetAnotherClown Date: Mon, 28 Oct 2024 17:05:29 -0400 Subject: [PATCH] Fix regression in LuaType.js My bad for not understanding the code and then over complicating things! --- .../src/components/LuaType.js | 26 +++++-------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/docusaurus-plugin-moonwave/src/components/LuaType.js b/docusaurus-plugin-moonwave/src/components/LuaType.js index 4473e9f..e4e31ba 100644 --- a/docusaurus-plugin-moonwave/src/components/LuaType.js +++ b/docusaurus-plugin-moonwave/src/components/LuaType.js @@ -25,31 +25,17 @@ function tokenize(code, isGroup) { } const readBalanced = (left, right) => { - const leftChars = left.split("") - const rightChars = right.split("") - - let leftDepth = 0 - let rightDepth = 0 - let buffer = "" let depth = 0 while (peek()) { - if (peek() === leftChars[leftDepth]) { - leftDepth++ + if (peek() === left) { depth++ - } else if (peek() === rightChars[rightDepth]) { - rightDepth++ - - if (rightDepth === rightChars.length) { - if (depth === 0) { - break - } else { - depth-- - } + } else if (peek() === right) { + if (depth === 0) { + break } else { - next() - continue + depth-- } } @@ -85,7 +71,7 @@ function tokenize(code, isGroup) { next() tokens.push({ type: "stringLiteral", - luaType: `[[${readBalanced("[[", "]]")}]]`, + luaType: `[[${readBalanced("[", "]")}]]`, }) next() } else {