diff --git a/packages/shader-lab/src/common/BaseScanner.ts b/packages/shader-lab/src/common/BaseScanner.ts index dd871e2b83..b637dcad78 100644 --- a/packages/shader-lab/src/common/BaseScanner.ts +++ b/packages/shader-lab/src/common/BaseScanner.ts @@ -101,14 +101,18 @@ export default class BaseScanner { } skipSpace(includeLineBreak: boolean): void { - const chars = this.peek(2); - let curChar = chars[0]; + let curChar: string; + + while (includeLineBreak) { + const chars = this.peek(2); + curChar = chars[0]; - if (includeLineBreak) { if (chars === "\r\n") { this.advance(2); } else if (curChar === "\n" || curChar === "\r") { this.advance(1); + } else { + break; } }