Skip to content

Commit

Permalink
🐛 Fix backslash parser allowing multiple newlines per single backslash
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAfroOfDoom committed May 20, 2024
1 parent ec8760d commit 059a825
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 43 deletions.
16 changes: 12 additions & 4 deletions __snapshots__/packages/core/test-out/parser/util.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 15 additions & 27 deletions __snapshots__/packages/mcfunction/test-out/parser/command.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions packages/core/src/parser/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,11 @@ export function concatOnTrailingBackslash<N extends Returnable>(
continue
}

// Create an index map that skips the trailing backslash + whitespace
// Create an index map that skips from the trailing backslash to the
// next line's first non-whitespace character
const from = src.getCharRange()
// skip the `\`
src.skip()
// skip trailing whitespace + newline + preceding whitespace on the next line
src.skipWhitespace()
src.nextLine()
src.skipSpace()
const to = src.getCharRange(-1)
indexMap.push({
inner: Range.create(wrappedStr.length),
Expand Down

0 comments on commit 059a825

Please sign in to comment.