diff --git a/.changeset/pink-pianos-allow.md b/.changeset/pink-pianos-allow.md new file mode 100644 index 000000000000..dbab099098cc --- /dev/null +++ b/.changeset/pink-pianos-allow.md @@ -0,0 +1,5 @@ +--- +swc_common: patch +--- + +fix(common): Fix `StringInput.end_pos` diff --git a/crates/swc_common/src/input.rs b/crates/swc_common/src/input.rs index d42cccbd3e97..546eeec0ef9c 100644 --- a/crates/swc_common/src/input.rs +++ b/crates/swc_common/src/input.rs @@ -15,6 +15,7 @@ pub struct StringInput<'a> { orig: &'a str, /// Original start position. orig_start: BytePos, + orig_end: BytePos, } impl<'a> StringInput<'a> { @@ -34,6 +35,7 @@ impl<'a> StringInput<'a> { orig: src, iter: src.chars(), orig_start: start, + orig_end: end, } } @@ -55,7 +57,7 @@ impl<'a> StringInput<'a> { } pub fn end_pos(&self) -> BytePos { - self.last_pos + self.orig_end } }