Skip to content

Commit

Permalink
Fix missing open/close at first indentation level
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Mar 4, 2021
1 parent 40a6827 commit 75441e2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
4 changes: 2 additions & 2 deletions examples/basic.stdout
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1:mainbasic::hierarchical-example version=0.1
1:main┐basic::hierarchical-example version=0.1
1:main├┐basic::hierarchical-example version=0.1
1:main│└┐basic::server host="localhost", port=8080
1:main│ ├─ms INFO basic starting
Expand Down Expand Up @@ -38,4 +38,4 @@
1:main│ ├─ms INFO basic exit
1:main│┌┘basic::server host="localhost", port=8080
1:main├┘basic::hierarchical-example version=0.1
1:mainbasic::hierarchical-example version=0.1
1:main┘basic::hierarchical-example version=0.1
4 changes: 2 additions & 2 deletions examples/quiet.stdout
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1:mainquiet::hierarchical-example version=0.1
1:main┐quiet::hierarchical-example version=0.1
1:main├─┐quiet::server host="localhost", port=8080
1:main│ ├─ms INFO quiet starting
1:main│ ├─ms INFO quiet listening
Expand All @@ -25,4 +25,4 @@
1:main│ ├─ms WARN quiet internal error
1:main│ ├─ms INFO quiet exit
1:main├─┘
1:main
1:main
4 changes: 2 additions & 2 deletions examples/stderr.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fibonacci_seq{to=5}
fibonacci_seq{to=5}
├─ms DEBUG Pushing 0 fibonacci
├─┐nth_fibonacci{n=0}
│ ├─ms DEBUG Base case
Expand Down Expand Up @@ -107,5 +107,5 @@ fibonacci_seq{to=5}
│ │ ├─┘
│ ├─┘
├─┘

INFO The first 5 fibonacci numbers are [1, 1, 2, 3, 5, 8]
20 changes: 10 additions & 10 deletions examples/wraparound.stdout
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1:mainwraparound::recurse i=0
1:main┐wraparound::recurse i=0
1:main├─ms WARN wraparound boop
1:main├─┐wraparound::recurse i=1
1:main│ ├─ms WARN wraparound boop
Expand All @@ -8,7 +8,7 @@
1:main│ │ │ ├─ms WARN wraparound boop
1:main│ │ │ ├─┐wraparound::recurse i=4
1:mainms WARN wraparound boop
1:mainwraparound::recurse i=5
1:main┐wraparound::recurse i=5
1:main├─ms WARN wraparound boop
1:main├─┐wraparound::recurse i=6
1:main│ ├─ms WARN wraparound boop
Expand All @@ -18,7 +18,7 @@
1:main│ │ │ ├─ms WARN wraparound boop
1:main│ │ │ ├─┐wraparound::recurse i=9
1:mainms WARN wraparound boop
1:mainwraparound::recurse i=10
1:main┐wraparound::recurse i=10
1:main├─ms WARN wraparound boop
1:main├─┐wraparound::recurse i=11
1:main│ ├─ms WARN wraparound boop
Expand All @@ -28,7 +28,7 @@
1:main│ │ │ ├─ms WARN wraparound boop
1:main│ │ │ ├─┐wraparound::recurse i=14
1:mainms WARN wraparound boop
1:mainwraparound::recurse i=15
1:main┐wraparound::recurse i=15
1:main├─ms WARN wraparound boop
1:main├─┐wraparound::recurse i=16
1:main│ ├─ms WARN wraparound boop
Expand All @@ -38,14 +38,14 @@
1:main│ │ │ ├─ms WARN wraparound boop
1:main│ │ │ ├─┐wraparound::recurse i=19
1:mainms WARN wraparound boop
1:mainwraparound::recurse i=20
1:main┐wraparound::recurse i=20
1:main├─ms WARN wraparound boop
1:main├─┐wraparound::recurse i=21
1:main│ ├─ms WARN wraparound boop
1:main│ ├─ms WARN wraparound bop
1:main├─┘
1:main├─ms WARN wraparound bop
1:main
1:main
1:mainms WARN wraparound bop
1:main│ │ │ ├─┘
1:main│ │ │ ├─ms WARN wraparound bop
Expand All @@ -55,7 +55,7 @@
1:main│ ├─ms WARN wraparound bop
1:main├─┘
1:main├─ms WARN wraparound bop
1:main
1:main
1:mainms WARN wraparound bop
1:main│ │ │ ├─┘
1:main│ │ │ ├─ms WARN wraparound bop
Expand All @@ -65,7 +65,7 @@
1:main│ ├─ms WARN wraparound bop
1:main├─┘
1:main├─ms WARN wraparound bop
1:main
1:main
1:mainms WARN wraparound bop
1:main│ │ │ ├─┘
1:main│ │ │ ├─ms WARN wraparound bop
Expand All @@ -75,7 +75,7 @@
1:main│ ├─ms WARN wraparound bop
1:main├─┘
1:main├─ms WARN wraparound bop
1:main
1:main
1:mainms WARN wraparound bop
1:main│ │ │ ├─┘
1:main│ │ │ ├─ms WARN wraparound bop
Expand All @@ -85,4 +85,4 @@
1:main│ ├─ms WARN wraparound bop
1:main├─┘
1:main├─ms WARN wraparound bop
1:main
1:main
9 changes: 9 additions & 0 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ fn indent_block_with_lines(
} else if indent_spaces == 0 {
for line in lines {
buf.push_str(prefix);
// The first indent is special, we only need to print open/close and nothing else
if indent == 0 {
match style {
SpanMode::Open { .. } => buf.push_str(LINE_OPEN),
SpanMode::Close { .. } => buf.push_str(LINE_CLOSE),
SpanMode::PreOpen | SpanMode::PostClose => unreachable!(),
SpanMode::Event => {}
}
}
buf.push_str(line);
buf.push('\n');
}
Expand Down

0 comments on commit 75441e2

Please sign in to comment.