thread 'main' panicked at 'get_lines should always return at least one line?'
I'm not sure exactly where in the code base this is referring to, but if I pass in an empty string as source, then have an error that references the span 0..1 of that source, I get this error. I can avoid the error by adding a newline or some character to the input.
This is part of the report handlers (both Narratable and Graphical).
The error could be improved, but it's worth noting that your example will fail anyway, since your span will be out of bounds for the available source text.
It is out of bounds, but the span is meant to represent EOI for the parser library I am using (Chumsky). This case is meant to handle if someone were to pass in a completely empty file, even though we do expect something (we don't expect the file to be empty) Is it better if I were to avoid erroring on empty files/strings?
Hmm. What happens if you just give it a 0-length span? That's perfectly valid. I guess that probably breaks?
But also it doesn't really make sense to display a labeled span for empty files, since... there's nothing to display. You can still use Diagnostic with an error message, code, help text, etc, ofc, but idk what you'd expect the renderer to do?