-
Notifications
You must be signed in to change notification settings - Fork 40
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
Don't split input over multiple lines in debug view. #516
Conversation
If the Input type is a slice, using `{:#?}` will insert newlines into the debug view. This messes up the output, which is counting charecters to fill a single line. Before: ``` > alt | [ Call @ 0..4, Ident > separated_foldl1 | [ Call @ 0..4, Ident > separated_foldl1 | [ Call @ 0..4, Ident > separated_foldl1 | [ Call @ 0..4, Ident > separated_foldl1 | [ Call @ 0..4, Ident > separated_foldl1 | [ Call @ 0..4, Ident > separated_foldl1 | [ Call @ 0..4, Ident > alt | [ Call @ 0..4, Ident > alt | [ Call @ 0..4, Ident > one_of | [ Call @ 0..4, Ident > any | [ Call @ 0..4, Ident ``` After: ``` > alt | [Call @ 0..4, Ident @ 5..19, > separated_foldl1 | [Call @ 0..4, Ident @ 5..19, > separated_foldl1 | [Call @ 0..4, Ident @ 5..19, > separated_foldl1 | [Call @ 0..4, Ident @ 5..19, > separated_foldl1 | [Call @ 0..4, Ident @ 5..19, > separated_foldl1 | [Call @ 0..4, Ident @ 5..19, > separated_foldl1 | [Call @ 0..4, Ident @ 5..19, > alt | [Call @ 0..4, Ident @ 5..19, > alt | [Call @ 0..4, Ident @ 5..19, > one_of | [Call @ 0..4, Ident @ 5..19, > any | [Call @ 0..4, Ident @ 5..19, ```
@@ -146,7 +146,7 @@ pub fn start<I: Stream>( | |||
|
|||
// The debug version of `slice` might be wider, either due to rendering one byte as two nibbles or | |||
// escaping in strings. | |||
let mut debug_slice = format!("{:#?}", input.raw()); | |||
let mut debug_slice = format!("{:?}", input.raw()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Test Coverage Report for Build 8898483497Details
💛 - Coveralls |
Ah, (ab)using impl fmt::Debug for Input<'_, '_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() {
let toks = self.remaining_input();
// Don't use Debug::fmt(f, toks) to force non-alternate writing, see winnow#516
write!(f, "{toks:?}")
} else {
f.debug_struct("Input")
.field("source", &self.source)
.field("offset", &self.offset)
.field("acx", &self.acx)
.finish()
}
}
} (where It does unfortunatly mean that |
See also #482 (comment), for some thaughts on a potential change to |
If the Input type is a slice, using
{:#?}
will insert newlines intothe debug view. This messes up the output, which is counting charecters
to fill a single line.
Before:
After: