mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:39:12 +00:00
ruff_annotate_snippets: support overriding the "cut indicator"
We do this because `...` is valid Python, which makes it pretty likely that some line trimming will lead to ambiguous output. So we add support for overriding the cut indicator. This also requires changing some of the alignment math, which was previously tightly coupled to `...`. For Ruff, we go with `…` (`U+2026 HORIZONTAL ELLIPSIS`) for our cut indicator. For more details, see the patch sent to upstream: https://github.com/rust-lang/annotate-snippets-rs/pull/172
This commit is contained in:
parent
a45f4de683
commit
84ba4ecaf5
5 changed files with 94 additions and 17 deletions
|
@ -210,7 +210,7 @@ impl std::fmt::Display for CodeFrame<'_> {
|
|||
.annotation(annotation)
|
||||
.fold(false);
|
||||
let message = Level::None.title("").snippet(snippet);
|
||||
let renderer = Renderer::plain();
|
||||
let renderer = Renderer::plain().cut_indicator("…");
|
||||
let rendered = renderer.render(message);
|
||||
writeln!(f, "{rendered}")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue