ruff/crates/ruff_annotate_snippets
Andrew Gallant 76619b96e5 [ty] Fix rendering of long lines that are indented with tabs
It turns out that `annotate-snippets` doesn't do a great job of
consistently handling tabs. The intent of the implementation is clearly
to expand tabs into 4 ASCII whitespace characters. But there are a few
places where the column computation wasn't taking this expansion into
account. In particular, the `unicode-width` crate returns `None` for a
`\t` input, and `annotate-snippets` would in turn treat this as either
zero columns or one column. Both are wrong.

In patching this, it caused one of the existing `annotate-snippets`
tests to fail. I spent a fair bit of time on it trying to fix it before
coming to the conclusion that the test itself was wrong. In particular,
the annotation ranges are 4 bytes off. However, when the range was
wrong, the buggy code was rendering the example as intended since `\t`
characters were treated as taking up zero columns of space. Now that
they are correctly computed as taking up 4 columns of space, the offsets
of the test needed to be adjusted.

Fixes #670
2025-06-26 11:12:16 -04:00
..
examples crates: vendor annotate-snippets crate 2025-01-15 13:37:52 -05:00
src [ty] Fix rendering of long lines that are indented with tabs 2025-06-26 11:12:16 -04:00
tests [ty] Fix rendering of long lines that are indented with tabs 2025-06-26 11:12:16 -04:00
Cargo.toml crates: vendor annotate-snippets crate 2025-01-15 13:37:52 -05:00
LICENSE-APACHE crates: vendor annotate-snippets crate 2025-01-15 13:37:52 -05:00
LICENSE-MIT crates: vendor annotate-snippets crate 2025-01-15 13:37:52 -05:00
README.md crates: vendor annotate-snippets crate 2025-01-15 13:37:52 -05:00

This is a fork of the annotate-snippets crate. The principle motivation for this fork, at the time of writing, is issue #167. Specifically, we wanted to upgrade our version of annotate-snippets, but do so without changing our diagnostic message format.

This copy of annotate-snippets is basically identical to upstream, but with an extra Level::None variant that permits skipping over a new non-optional header emitted by annotate-snippets.

More generally, it seems plausible that we may want to tweak other aspects of the output format in the future, so it might make sense to stick with our own copy so that we can be masters of our own destiny.