Commit Graph

464 Commits

Author SHA1 Message Date
Lucas Holten 0bf3daebc2 Revert to passing around SpanContents 2024-01-11 10:11:42 +01:00
Lucas Holten 997a3ea782 Choose primary label from inside the context 2023-12-13 13:46:38 +01:00
Lucas Holten d4f30ec501 Clean up render_snippets 2023-12-13 13:46:38 +01:00
Jonathan Dönszelmann 7ff4f874d6
fix(graphical): rendering bug on small spans in large spans (#316)
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.
2023-11-15 11:40:16 -08:00
Jonathan Dönszelmann 865d67c8dd
feat(graphical): support rendering labels that contain newlines (#318)
Fixes: https://github.com/zkat/miette/issues/85
2023-11-15 10:39:29 -08:00
Jonathan Dönszelmann 251d6d5929
fix(docs): add example to README and docs fixing #96 (#319) 2023-11-15 10:35:46 -08:00
Zanie Blue fd77257cee
feat(graphical): Expose additional `textwrap` options (#321) 2023-11-15 10:34:24 -08:00
ManicMarrc c7ba5b7e52
feat(derive): Make `miette-derive` be able to be turned off (#304) 2023-11-09 13:22:47 -08:00
Benjamin Lee 3d6f903df0
fix(formatting): Fix formatting bug when an empty span is not aligned to a char boundary (#314)
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.
2023-11-09 13:21:32 -08:00
Matt a8b4ae012a
fix(graphical): Extend error text span to whole code points (#312)
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.
2023-11-02 09:33:55 -07:00
Andre Meyering d37ada876a
docs(README): Move import of `NamedResult` to where it is used (#309)
An example in README.md makes use of `miette::NamedResult` .
It is imported in the second "example-step", but already used in the first one. Beginners, that copy the example step-by-step to understand it, will run into compile errors, as `NamedResult` was not imported.
2023-10-23 10:09:00 -07:00
Gavrilikhin Daniil 88d00e0e20
feat(derive): Allow optional sources in derive (#301)
Fixes: https://github.com/zkat/miette/issues/217
2023-10-20 20:50:15 -07:00
Thomas Versteeg ba313282a8
docs: typo in README.md (#295)
Dynamic diagnostics example contains a macro invocation without a '!' symbol.
2023-09-29 06:56:09 -07:00
Bruce Mitchener 06b348230a
fix(clippy): Add missing semicolons where nothing is returned. (#293) 2023-09-25 10:33:07 -07:00
Bruce Mitchener 1f448e4775
fix(tests): Fix `cargo test` with default features. (#294)
A couple of tests require `fancy-no-backtrace`, so mark them
accordingly.
2023-09-25 10:31:44 -07:00
Will Crichton db0b7e403a
feat(labels): Add support for primary label in specifying line/col information (#291) 2023-09-20 15:36:33 -07:00
Bruce Mitchener cc81382a60
fix(misc): Improve ci and fix clippy (#290)
* 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.
2023-09-20 10:37:40 -07:00
Bruce Mitchener a9c2bae9dc
docs: Improve linking. (#289) 2023-09-18 09:12:56 -07:00
Kat Marchán f4d056e1ff
chore: Release 2023-07-15 18:49:14 -07:00
Kat Marchán f8d1382501
docs: update changelog 2023-07-15 18:48:59 -07:00
Kat Marchán 10c3b7f809
docs: update readme again 2023-07-15 18:48:00 -07:00
Gavrilikhin Daniil bfacb6329f
doc: document `#[diagnostic(transparent)]` (#266) 2023-07-15 18:46:54 -07:00
Bruce Mitchener c3d4db2618
docs: Fix broken links from macro docs. (#278) 2023-07-07 17:16:53 -07:00
Bennett Hardwick 2e3e5c9d15
feat(protocol): add StdError impl for Box<dyn Diagnostic + Send + Sync> (#273) 2023-06-28 18:58:35 -07:00
0x009922 89806755a4
docs: a little cleaning in README (#274) 2023-06-28 18:42:12 -07:00
Khang Nguyen Duy 01b60a7df8
docs: fix broken links (#275)
the links point to structs, whereas it should be traits
2023-06-24 22:15:28 -07:00
Kat Marchán 91e5f5b7e3
chore: Release 2023-05-18 15:58:11 -07:00
Kat Marchán b1d74e351d
docs: update changelog 2023-05-18 15:57:33 -07:00
Marcel Müller aefe323780
feat(nested): Render inner diagnostics (#170) 2023-05-18 15:41:17 -07:00
kleines Filmröllchen 46adb3bc6a
feat(const): Constify various functions (#263)
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.
2023-05-17 15:42:42 -07:00
Gavrilikhin Daniil c25676cb1f
feat(serde): Add `serde` support (#264)
Fixes: https://github.com/zkat/miette/issues/260
2023-05-14 01:43:40 -07:00
Gavrilikhin Daniil 024145dbdd
Add dynamic diagnostic (#262) 2023-05-13 13:59:43 -07:00
Alexander Seiler 675f3411e3
fix(misc): Correct some typos (#255)
Signed-off-by: Alexander Seiler <seileralex@gmail.com>
2023-04-25 21:07:18 -07:00
Kat Marchán 2b4d67d7cd
chore: Release 2023-04-18 08:56:10 -07:00
Kat Marchán 1692d99fa8
docs: update changelog 2023-04-18 08:56:02 -07:00
Kat Marchán adbff65e4e
fix(narrated): put URLs in their own line
This makes it easier for screen readers to access/visit.
2023-04-18 08:55:18 -07:00
Andrew Hickman be3b254751
feat(source): Add getter for NamedSource name (#252) 2023-04-18 08:55:08 -07:00
Kat Marchán 80c6ce805b
chore: Release 2023-03-31 17:25:26 -07:00
Kat Marchán b1276c4df5
docs: update changelog 2023-03-31 17:25:01 -07:00
Kat Marchán b0453215f6
feat(panic): improved backtrace handling
Fixes: https://github.com/zkat/miette/issues/92
2023-03-31 17:08:20 -07:00
Aria Beingessner 0b445dc2b4
fix(tests): disable doctest that doesn't work with default feature flags (#248) 2023-03-30 09:19:51 -07:00
Aria Beingessner 159f2b354b
fix(colors): change unicode to default to ansi (#249) 2023-03-30 09:18:52 -07:00
Yoni Feng 566d6be6e3
misc(perf): nit perf improvements (#244) 2023-03-29 20:21:40 -07:00
jtroo a215720576
feat(deps): update to syn2 (#247)
Fixes: https://github.com/zkat/miette/issues/243
2023-03-29 18:11:14 -07:00
Kat Marchán 78fe18e699
chore: Release 2023-03-13 21:15:55 -07:00
Kat Marchán 2335b25ee7
docs: update changelog 2023-03-13 21:15:33 -07:00
George Pollard 443d240f49
fix(atty): Switch out `atty` for `is-terminal` (#229) 2023-03-13 21:10:21 -07:00
Erich Gubler ed486c959d
feat(protocol): implement `Ord` for `Severity` (#240)
Fixes: https://github.com/zkat/miette/issues/239
2023-03-01 15:48:11 -08:00
dalance 3497508aa9
fix(graphical): Fix wrong severity of related errors (#234) 2023-02-08 16:26:27 -08:00
Kat Marchán b658fc020b
fix(ci): configure clippy-specific MSRV 2023-02-08 16:06:11 -08:00