-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
consider the hard-coding of ...
as an indicator that a line has been trimmed or cut
#174
Comments
Popping up a level, is it useful if I keep sending patches to this project? Putting myself in y'all's shoes, I'd be tempted to constrain the complexity of this specific project and reject patches like this that arguably increase API complexity and potentially also the layout logic as well. I feel like coupling for a project like this is a great simplifier. (I can still upsteam what I think are bug fixes as I come across them, so long as our code doesn't diverge too much internally.) |
Like I said in another place, our primary focus is on cargo/rustc while we figure out what is needed for the current stage and then we'll be a bit more open to explore what generalizations make sense. Personally, I'd rather it not be completely themable because I suspect that will lead to too much complexity and having some level of consistency and sharing of best practices would be good, kind of like how I push back on some clap customization to encourage people making clap better for everyone or because consistency might be better than their slight optimization for their one use (besides binary size / compile times) This doesn't mean we are against supporting outside needs but it won't get prioritized or it might get pushed back. I can understand not wanting to block your development when you have a product to deliver and working off of a fork. |
All righty, that makes sense! In the interest of being concrete, here's what I'll do for now (unless they're are any objections or other opinions):
Happy to revisit this as needed. |
As I mentioned in #172, there are two potential problems with this
I like the idea of using that unicode character but that would be blocked on having the rest of our unicode styling and a fallback would be needed for ASCII. It also seems like the elided text should be styled differently than source. Maybe dimmed? Or to style the same as |
I'd say feel free to open issues for anything you don't upstream, and note in it that your fork has it implemented, so that we can double check your assumptions of how well we can adopt it now and to make sure we are keeping in mind wider needs as we design the current stages. Like I said, I would love there to be as little to no divergence as possible. |
@BurntSushi it looks like we already color annotate-snippets-rs/src/renderer/display_list.rs Lines 351 to 357 in 32dc464
For an example screenshot, see https://github.com/rust-lang/annotate-snippets-rs/blob/master/tests/fixtures/color/strip_line_non_ws.svg Are you customizing the colors, is the color no enough, or is the concern for color-stripped output? |
I think that definitely helps, but I'm still a little concerned about relying on color for resolving ambiguity. Color might not be enabled for one reason or another (there are plenty of times where I myself will be looking at rustc diagnostics, for example, without color). And I guess there are accessibility concerns there too, although I'm not an expert in that domain. Like, I do think it's reasonable to use color as a mitigating factor here since, as I mentioned, I don't think it's possible to be perfect. cc @MichaReiser if you have any opinions here as the person who originally brought up this concern. The context here I think is seeing whether we can come to a consensus on one string for indicating a cut line instead of making it configurable. (If I'm understanding @epage correctly here.) |
Also, I will confess that I don't quite understand the intricacies of making the cut indicator a non-ASCII string. Basically, I think this
and this
went over my head. My knowledge of |
Colors definitely help. I wasn't aware of the coloring because it doesn't show in our snapshots. It would still be great to have a non-color indicator that distinguishes the trimming sequence from a regular |
Cargo is very conservative in what terminals it supports, so it unicode support is gated behind https://crates.io/crates/supports-unicode with a I'm unsure what @Muscraft has planned for unicode support. In theory, a bool could be thrown on the renderer and offer this but I also know Muscraft is in the middle of a big change to the renderer. |
We snapshot with |
Ref #172
The high level problem I ran into with integrating
annotate-snippets
into Rust---and specifically, an upgrade from0.9
to0.11
---was that trimming long lines automatically inserts a...
. This is somewhat problematic in Python specifically because a...
is itself valid Python and not that uncommon. For example, with...
, it's hard to tell the difference between a line being trimmed and an actual line. Here's an actual example where it's ambiguous:I futzed with the terminal width here a bit to make it ambiguous for this specific snippet, but I think this gets the idea across.
In #172, I tried to approach this problem by making it possible to override the indicator to something else. For us, we're thinking of using
…
(U+2026 HORIZONTAL ELLIPSIS
) since it gets the same idea across, but should hopefully be less confusable with actual Python syntax. Of course, I think it's true that any choice here could always risk being confusable, but...
is far less likely to result in ambiguity for, e.g., Rust code than it is for Python code.The text was updated successfully, but these errors were encountered: