Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jun 11, 2024
1 parent 7e52db7 commit 5ac0b83
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion crates/swc_ecma_parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1219,8 +1219,17 @@ impl<'a> Lexer<'a> {
} else if c.is_line_terminator() {
self.state.had_line_break = true;

{
let last_pos = self.cur_pos();
raw.push_str(unsafe {
// Safety: Both of start and last_pos are valid position because we got them
// from `self.input`
self.input.slice(raw_slice_start, last_pos)
});
}

let c = if c == '\r' && self.peek() == Some('\n') {
// raw.push('\r');
raw.push('\r');
self.bump(); // '\r'
'\n'
} else {
Expand All @@ -1238,6 +1247,8 @@ impl<'a> Lexer<'a> {
if let Ok(ref mut cooked) = cooked {
cooked.push(c);
}
raw.push(c);
raw_slice_start = self.cur_pos();
} else {
self.bump();

Expand Down

0 comments on commit 5ac0b83

Please sign in to comment.