Skip to content

Conversation

@Swatinem
Copy link
Member

@Swatinem Swatinem commented Nov 9, 2022

With suggestions applied and clippy fixed again
#53

jridgewell and others added 8 commits October 24, 2022 23:37
The old code improperly found the section to call recurse into. Sourcemap sections behave very similarly to the mappings, and we need to find the section whose offset is `<=` the desired position.

Additionally, the `col` is only subtracted if it is on the offset's line. This matches [Mozilla's behavior](https://github.com/mozilla/source-map/blob/0.6.1/lib/source-map-consumer.js#L1000-L1003).

And as a final bonus, we can binary search it to speed up searches on larger maps.
Token lookup uses "greatest lower bound" lookups, which means we need to find the token on the line which is `<=` than our desired column. But, the old code accidentally considered the last token to span infinite columns and infinite lines, meaning a lookup of `(10000000, 0)` would return the last token.
@Swatinem Swatinem enabled auto-merge (squash) November 9, 2022 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants