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

Allow Spans to be byte offset based instead of char offset based #71

Closed
brockelmore opened this issue Apr 18, 2023 · 2 comments
Closed

Comments

@brockelmore
Copy link

I use a parser which reports code locations as byte spans instead of char spans. It would be nice if via config we could specify byte offsets instead of char offsets.

One way would be in this line:

let len = line.chars().count();

to switch to:

let len = line.chars().fold(0, |mut acc, i| {acc += i.len_utf8(); acc });

based on the configuration. Of note, this actually fixes some of the spacing issues like in #41 if the location producer also uses bytes.

@zesterer
Copy link
Owner

zesterer commented Apr 19, 2023

This will probably happen at some point, when I have more time to work on the crate. See #8.

@brockelmore
Copy link
Author

Oh sorry I tried to find an issue for this but missed this! Thanks, will close this one.

VonTum added a commit to VonTum/ariadne that referenced this issue Feb 29, 2024
Closes zesterer#8
Closes Duplicate issues zesterer#71 and zesterer#57
zesterer pushed a commit that referenced this issue Mar 7, 2024
Closes #8
Closes Duplicate issues #71 and #57
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