zesterer / ariadne

A fancy diagnostics & error reporting crate
https://crates.io/crates/ariadne
MIT License
1.79k stars 78 forks source link

Add byte spans #102

Closed VonTum closed 8 months ago

VonTum commented 9 months ago

I've added the possibility to use byte spans at the Report level. You can configure using byte spans by calling

report_builder.with_config(Config::default().with_index_type(IndexType::Byte))

I went down a few paths in trying to implement this without API breaks, before settling on making it configurable in the ReportBuilder. Doing it this way allows the user to use the same Span types as before, just with byte indices.

I performed this addition in two steps. Refactoring write.rs to store the computed char span in LabelInfo's char_span : Range<usize> field everywhere. In the second part I convert the given byte spans to char spans, if the Report's been configured to.

zesterer commented 8 months ago

Thanks for the PR! Sorry about the delay in responding, I'm going to try to find time to review this over the next day.

zesterer commented 8 months ago

Thanks for the superb PR. Usually with a PR of this length I challenge myself to find at least one problem with it, but I'm at a loss here: all looks good. Thanks again!

zesterer commented 8 months ago

Reminder to self: update changelog and bump version

VonTum commented 8 months ago

That is quite the compliment! Thank you :smile:

goto-bus-stop commented 8 months ago

great news, thank you both! 🥳