Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(swc_ecma_codegen): fix LineCol calculation of printed files #6763

Merged
merged 1 commit into from
Jan 8, 2023

Commits on Jan 7, 2023

  1. fix(swc_ecma_codegen): fix LineCol calculation of printed files

    There were several issues with the way we updated the current `LineCol` position during the printing of the generated file:
    
    - We used `chars` and `char_indices` (UTF-32) instead of `encode_utf16` (UTF-16) chars.
      - JS uses UCS-2 (basically UTF-16) for its strings, and sourcemaps default to that implicitly.
    - `\r` was incorrectly handled
      - it didn't add a `line_start`, only `\n` did
    - `\r\n` was incorrectly handled
      - It was trying to let `\n` path handle the `line_start`, but it called `chars.next()` which ate the `\n` char.
    
    I also took the opportunity to avoid the `Vec` allocations and reduced some code duplication.
    jridgewell committed Jan 7, 2023
    Configuration menu
    Copy the full SHA
    aa74735 View commit details
    Browse the repository at this point in the history