-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Trailing whitespace characters #52
Comments
I'm happy to accept the PR that implements this, although unfortunately I'm probably not going to have the time to commit to implementing it myself for at least a few weeks. |
I had a go for an hour but didn't quite get there; let me post what I did — if I'm close then possibly I can have another go at the weekend. This is the standard We want to remove the
(here's the code I used to get the diff --git a/src/write.rs b/src/write.rs
index 9326f84..b11d245 100644
--- a/src/write.rs
+++ b/src/write.rs
@@ -506,7 +506,7 @@ struct LineLabel<'a, S> {
} else if let Some(underline_ll) = underline {
[draw.underline.fg(underline_ll.label.color); 2]
} else {
- [' '.fg(None); 2]
+ ['x'.fg(None); 2]
};
for i in 0..width { By adjusting the arrow line length, we can remove some of the endings, but a) that's doing too much and b) it doesn't remove the others. diff --git a/src/write.rs b/src/write.rs
index 9326f84..a0785ee 100644
--- a/src/write.rs
+++ b/src/write.rs
@@ -411,7 +411,8 @@ struct LineLabel<'a, S> {
line_labels.sort_by_key(|ll| (ll.label.order, ll.col, !ll.label.span.start()));
// Determine label bounds so we know where to put error messages
- let arrow_end_space = if self.config.compact { 1 } else { 2 };
+ let arrow_end_space = 0;
let arrow_len = line_labels
.iter()
.fold(0, |l, ll| if ll.multi {
The main issue seems to be that we need to know in the loop whether we've finished writing the significant characters, and I wasn't sure of a reasonable way of doing that. Ofc the alternative is to do another pass at the end, but that seems like a very clunky solution for a relatively small problem. |
Firstly thank you for the excellent library! We're heavily using it in PRQL.
In PRQL we have a pre-commit action which removes trailing whitespace. It seems that ariadne's outputs have trailing whitespace, so inline snapshot tests can't pass. Here's an example: PRQL/prql@80ae431, from PRQL/prql#1181.
Would it be reasonable to strip trailing whitespace? Or is that too narrow a goal? It's not that critical for us; we can move to using snapshot tests in
.snap
files if needed.Thanks again
The text was updated successfully, but these errors were encountered: