Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jridgewell index #54

Merged
merged 8 commits into from
Nov 9, 2022
Merged

Jridgewell index #54

merged 8 commits into from
Nov 9, 2022

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