The default `GraphicalReportHandler` disables the printing of cause
chains for any inner errors (errors `related()` to a source diagnostic)
when it disables nested footer printing. This results in lost cause
chain information when printing with the default report handler.
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.
* ci: Update actions, replace actions-rs.
* `actions/checkout` is updated from `v1` to the current `v4`.
* `actions-rs/toolchain` is replaced by `dtolnay/rust-toolchain` as
the `actions-rs` actions haven't been maintained in a long time.
* clippy: Remove unnecessary call to `into_iter`.
The parameter takes `IntoIterator`, so we don't have to call
`into_iter` at the call site.
* clippy: Remove explicit lifetime that can be elided.
* clippy: tests: Fix useless conversion warnings.
* clippy: tests: Remove call to `format!`.
* Fix minimal-versions build.
Due to changes in the nightly compiler, using a recent nightly
requires proc-macro2 1.0.60 or later:
https://github.com/dtolnay/proc-macro2/issues/356
* ci: Use is-terminal 0.4.7 for MSRV builds.
is-terminal 0.4.8 updated its MSRV to 1.63, so we can't use it
with our MSRV of 1.56. Force usage of the older version which has
an older MSRV.
This is primarily aimed at making `SourceSpan` and `SourceOffset` usable
in const contexts.
Constifiable functions were found with the
`clippy::missing_const_for_fn` lint, though it reported at least two
false positives.
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.
This is already currently accessible with `miette!`, but I missed that
because it isn't clearly documented. Add a constructor to mirror
`Report::new` and `Report::msg`.
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>
Fixes: https://github.com/zkat/miette/issues/176
Change the default ansi color theme to use colors that are more similar
to the colors from the default RGB theme. In particular, don't use red
for any of the span labels, since that color is also used for errors.
BREAKING CHANGES:
* the default theme now prefers ANSI colors, even if RGB is supported
* `MietteHandlerOpts::ansi_colors` is removed
* `MietteHandlerOpts::rgb_color` now takes an enum that controls the
color format used when color support is enabled, and has no effect
otherwise.
Fixes: https://github.com/zkat/miette/issues/160
This patch expands on the effects of using IntoDiagnostic and warns
users of potential loss of information when using it on `Diagnostic`
types.
* 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).
Techically there was a hidden undocumented `context` method. But it was
just copied from the `eyre` and there is no evidence that it was used by
any user in miette (the method was an alias for `.handler()`).
Fixes#108
Fixes#106
While fixing the bug I've also extended the handler to print not just
where label starts but also where label ends.
Also implements #97, but for narratabble handler only.
This adds dependency on `unicode-width`, but it was already in the
dependency chain (`textwidth` depends on it). Although, previously it
was only for `"fancy"` feature, now it always required since narratable
handler is supported without `"fancy"`.