zesterer / ariadne

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

Use line numbers instead of character position #20

Closed ryangjchandler closed 1 year ago

ryangjchandler commented 2 years ago

Is it possible to render errors based on line number and then the column? My parser resets the column position on each new line, so rendering errors is difficult since an error on the 4th line at column 4..5 is being rendered as the 4th and 5th characters in the entire source.

zesterer commented 2 years ago

This is not currently possible, but I might be able to build this feature into the API refactor I'm working on.

ryangjchandler commented 2 years ago

Yeah that would be awesome.

kaplanelad commented 1 year ago

Hey @zesterer, any update regarding this issue?

zesterer commented 1 year ago

I think this should be possible with the offset method on Source: https://docs.rs/ariadne/latest/ariadne/struct.Line.html#method.offset.