jsonc-parser
jsonc-parser copied to clipboard
common::Ranged provides method to convert to line/col from byte index
Like Ranged::text()
, taking the original text, it would be great to be able to return a (usize, usize)
that returns a line and column variant, which is more used when displaying positions to users or editors.
That sounds good! Probably would just do a simple iteration of all the chars leading up to the position each time to compute this.
By the way, another possibility might be to use text_lines for this. It’s already in the CLI https://github.com/dsherret/text_lines
The ParseResult
could contain the line index (as an parse option) which would make it easy to coerce into a line/col.