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

results from SourceMap::lookup_token is not correct #7

Closed
Brooooooklyn opened this issue Dec 28, 2017 · 6 comments
Closed

results from SourceMap::lookup_token is not correct #7

Brooooooklyn opened this issue Dec 28, 2017 · 6 comments

Comments

@Brooooooklyn
Copy link

you can find a playground project in https://github.com/Brooooooklyn/sourcemap-issue

and yarn && yarn start to see the follow result:

let s = sm.lookup_token(1, 113946).unwrap()
println!("content: {}, column: {}", s.get_source().unwrap(), s.get_src_line());
// '../static/js/main.4a1cd49f.js', 2357

and the result from https://www.npmjs.com/package/source-map:

const jsDecoder = new SourceMapConsumer(sourcemap)
const jsResult = jsDecoder.originalPositionFor({
  line: 1,
  column: 113946
})

console.log(jsResult)
// { source: 'service.ts', line: 10, column: 0, name: null }
@Brooooooklyn
Copy link
Author

@mitsuhiko

@mitsuhiko
Copy link
Member

The line and column are zero indexed on lookup. Presumably you are passing wrong data.

@Brooooooklyn
Copy link
Author

that's wired, because the same file is decoded correctly by https://www.npmjs.com/package/source-map

@mitsuhiko
Copy link
Member

@Brooooooklyn not sure what you mean. this library intentionally uses zero indexed values so you are passing the wrong values into the lookup functions.

@mitsuhiko
Copy link
Member

To clarify that: if you want to look up line 1 and column 1 you need to pass (0, 0) and not (1, 1).

@Brooooooklyn
Copy link
Author

Oh, I get it , sorry for my misunderstanding.

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

No branches or pull requests

2 participants