mirror of
https://github.com/swc-project/swc.git
synced 2024-12-24 22:22:34 +03:00
fix(es/codegen): Fix sourcemap bug related to multi-line comments (#3023)
swc_ecma_codegen: - Compute line starts in multi-line comments.
This commit is contained in:
parent
f86c077a37
commit
c415487bb9
@ -184,6 +184,13 @@ impl<'a, W: Write> WriteJs for JsWriter<'a, W> {
|
||||
|
||||
fn write_comment(&mut self, span: Span, s: &str) -> Result {
|
||||
self.write(Some(span), s)?;
|
||||
{
|
||||
let line_start_of_s = compute_line_starts(s);
|
||||
if line_start_of_s.len() > 1 {
|
||||
self.line_count = self.line_count + line_start_of_s.len() - 1;
|
||||
self.line_pos = s.len() - line_start_of_s.last().cloned().unwrap_or(0);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user