Skip to content

Commit 2b87596

Browse files
committed
fix: Tokens only extend to the end of the line
This is the `sourcemapcache` equivalent of getsentry/rust-sourcemap#131 (but does not depend on it). Previously, when looking up a line and column, we would always return the token at or immediately before that position, even if it belonged to an earlier minified line. This is 1. wrong—tokens are only meant to extend to the end of a line. 2. inconsistent—this means that an unmapped line before any mapped line would return no mapping, but an unmapped line after a mapped line would.
1 parent bd27cc8 commit 2b87596

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

symbolic-sourcemapcache/src/lookup.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ impl<'data> SourceMapCache<'data> {
177177
Err(idx) => idx - 1,
178178
};
179179

180+
// If the token has a lower minified line number,
181+
// it actually belongs to the previous line. That means it should
182+
// not match.
183+
if self.min_source_positions.get(idx)?.line < sp.line {
184+
return None;
185+
}
186+
180187
let sl = self.orig_source_locations.get(idx)?;
181188

182189
// If file, line, and column are all absent (== `u32::MAX`), this location is simply unmapped.

0 commit comments

Comments
 (0)