Skip to content

Commit

Permalink
Don't split input over multiple lines in debug view.
Browse files Browse the repository at this point in the history
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,
```
  • Loading branch information
aDotInTheVoid committed Apr 30, 2024
1 parent 8512ab7 commit 02bec58
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/combinator/debug/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
let (debug_slice, eof) = if let Some(debug_offset) = debug_slice
.char_indices()
.enumerate()
Expand Down

0 comments on commit 02bec58

Please sign in to comment.