From 5368e189ab5227a5cfdb53dc1105b787665a1c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 1 Aug 2024 15:01:32 +0900 Subject: [PATCH] fix(common): Fix `StringInput.end_pos` (#9362) --- .changeset/pink-pianos-allow.md | 5 +++++ crates/swc_common/src/input.rs | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/pink-pianos-allow.md 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 } }