Fixes: https://github.com/zkat/miette/issues/219
When a snippet couldn't be read (typically because the span didn't fit
within the source code), it and the rest of the diagnostic were silently
dropped, which was confusing to the developer.
Now, in place of the snippet, print an error message with the name of
the failed label and the error it triggered, then proceed with the rest
of the diagnostic (footer, related, ...)
The commit e5c7ae4 seemed to (potentially erronously?) remove a number of
spaces following the left `|` bar of some graphical report handler tests.
That change had no effect on the `syntax_highlighter_on_real_file()`
test, presumably because the trailing whitespace is removed by
`strip_ansi_escapes::strip_str()`, but it did break the
`triple_adjacent_highlight()` and `non_adjacent_hightlight()` tests.
Restoring the spaces removed in e5c7ae4 fixes the failing tests on main.
* fix(ci): move from minimal-versions to direct-minimal-versions
Fixes: https://github.com/zkat/miette/issues/317
It turned out there were two really. One related to how many characters
were added for the arrowheads in the gutter, and one where the gutter
was extended to a number of characters, including ansi escape codes.
However, because ansi escape codes are rather big, there would never be
any extension since the system thought the string was already long
enough, even though you don't actually see the width of those codes.
Previous output looked like this:
---- single_line_with_wide_char_unaligned_span_empty stdout ----
Error: oops::my::bad
× oops!
╭─[bad_file.rs:2:4]
1 │ source
2 │ 👼🏼text
· ─▲
· ╰── this bit here
3 │ here
╰────
help: try doing it better next time?
Note that the .max(start + 1) term is still necessary in the nonempty
branch, since it's possible to have a nonempty span covering zero-width
text.
* remove uncessary if statement
start > end in all cases.
Fixes: https://github.com/zkat/miette/issues/223
This fixes a panic when an error starts inside a Unicode code point. The
range is extended to start (or end) at the beginning (or end) of the
character inside which the byte offset is located.
Fixes: #215
This also changes the behavior with spans including a CRLF line-ending.
Before the panic bug was introduced, these were rendered with the CRLF
being two visual columns wide. Now, any span extending past the EOL is
treated as including one extra visual column.
Fixes: https://github.com/zkat/miette/issues/97
Fixes: https://github.com/zkat/miette/issues/87
Tabs are always expanded to spaces by the graphical handler, and `tab_width` now defaults to 4. Instead of replacing every tab with a fixed number of spaces, spaces are used to align to the next tabstop. `tab_width` controls the space between tabstops rather than the fixed width of each tab character.
Co-authored-by: Benjamin Lee <benjamin@computer.surgery>
* Fixed/formatted all intradoc links. Various other small doc fixes/typography/etc.
* Clarified semantic similarity with anyhow/eyre types/macros.
* Removed unused MietteError::SetPrinterFailure.
* README now generaed from lib.rs via `cargo readme`.
* More doc fixes, made ErrorHook type public.
* Indentation (docs).