Skip to content

Commit

Permalink
Fix regression in LuaType.js
Browse files Browse the repository at this point in the history
My bad for not understanding the code and then over complicating things!
  • Loading branch information
YetAnotherClown committed Oct 28, 2024
1 parent 93fe073 commit 05e69f9
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions docusaurus-plugin-moonwave/src/components/LuaType.js
Original file line number Diff line number Diff line change
Expand Up @@ -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--
}
}

Expand Down Expand Up @@ -85,7 +71,7 @@ function tokenize(code, isGroup) {
next()
tokens.push({
type: "stringLiteral",
luaType: `[[${readBalanced("[[", "]]")}]]`,
luaType: `[[${readBalanced("[", "]")}]]`,
})
next()
} else {
Expand Down

0 comments on commit 05e69f9

Please sign in to comment.