From 4e8747a7cdc21b51ee88cea499dfb0a6240ca0cf Mon Sep 17 00:00:00 2001 From: Paul C Roberts Date: Thu, 11 Jul 2024 16:17:41 -0700 Subject: [PATCH] Fix bug in common sub-expression matching A line can have unbalanced paren. This ensures that a closing paren has a corresponding open on the same line. --- src/make-wgsl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/make-wgsl.ts b/src/make-wgsl.ts index f6a2a2f..7497f2f 100644 --- a/src/make-wgsl.ts +++ b/src/make-wgsl.ts @@ -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--) {