Skip to content

Commit

Permalink
Fix bug in common sub-expression matching
Browse files Browse the repository at this point in the history
A line can have unbalanced paren. This ensures that a closing paren has a corresponding open on the same line.
  • Loading branch information
PollRobots committed Jul 11, 2024
1 parent 636a1b0 commit 4e8747a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/make-wgsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ const postProcessImpl = (lines: string[], indent: string): string => {
const ch = line.charAt(i);
if (ch === "(") {
starts.push(i);
} else if (ch === ")") {
} else if (ch === ")" && starts.length > 0) {
let start = starts.pop()!;
// check previous character until either '(' or ' ' is found
for (let j = start - 1; j >= 0; j--) {
Expand Down

0 comments on commit 4e8747a

Please sign in to comment.